-
Notifications
You must be signed in to change notification settings - Fork 6
Haskell
A popular whimsical book available on the web for free, often suggested as the first place to start for learning Haskell.
Many Haskell tutorials are more like guided tours of the language's features Write Yourself a Scheme is all about practice. If you need to get your hands dirty with Haskell this will help out.
Real World Haskell from O'Reilly
Although it is becoming dated, this is still a frequently-referenced resource thoroughly covering Haskell fundamentals.
The lecture notes and assignments make a good supplement to Learn You a Haskell, since it follows a similar curriculum. Brent Yorgey's material has been popular in the community and is also available on School of Haskell. The Brisbane Functional Programming Group has recorded some talk videos that follow the 2013 lecture notes.
- Spring 2013 by instructor Brent Yorgey.
- Spring 2015 by instructor Noam Zilberstein, covers some material different from 2013 in the later part of the course.
This course is designed to give a comprehensive introduction to functional programming using Haskell as the primary language. The lectures are fun and of just the right length with good exercise questions. The programming assignments are quite easy but are good enough to get the theoretical concepts through to the student. Overall, a good course for someone who has some experience in programming but knows nothing about functional programming or Haskell.
This has grown to cover a huge amount of ground, from language and concepts to tools. A good place to check for short, terse reference information.
If you've learned the basic language syntax, try some hands-on Haskell coding exercises. Exercism presents problems to solve with failing tests, urging to write code to get the tests passing. This is similar to the style of koans, but with an added (optional) element of online peer review.
This is a brief getting started guide—you can find more detailed ones from other resources, but this should get you going within a few minutes at a hack night.
If you're just starting Haskell development for the first time, I recommend you start with the Stack tool set. Stack is a build tool and dependency manager that will install the Haskell compiler (GHC) for you automatically if needed, so it's the only thing you need to install. Another popular choice is the Haskell Platform, which includes the Cabal build system tooling, comparable to maven
, pip
, gem
, npm
, composer
, etc. if you're familiar with those tools for other languages. Stack builds upon Cabal and has similar commands, but it emphasizes using the Stackage repository for stable sets of package releases, among some other extra features. You may have a smoother experience using Stack, but you will likely find more guides showing cabal
usage since it is older and more of a community standard to-date. The choice is up to you.
Stack is steadily gaining adoption, now featured as on option on the official haskell.org site. You can read more about how Stack aims to improve the Haskell tooling experience.
Install your choice of the tools according to the links above, or check your OS package manager—for Homebrew on OS X for instance, you can brew install haskell-stack
, or brew tap caskroom/cask
followed by brew cask install haskell-platform
.
Once you've installed one of the toolsets, starting and building projects will look like this:
$ stack new helloworld
$ cd helloworld
$ stack setup # Installs Haskell compiler (GHC) if needed.
$ stack build
$ stack exec helloworld-exe
Stack uses sandbox-like project isolation functionality by default, so you don't encounter version conflicts for dependencies used across multiple Haskell projects.
For more, read the full Stack user guide, or try a comprehensive video tutorial if you like learning by video.
$ mkdir helloworld && cd helloworld
$ cabal update # First time: refresh cabal's index of the latest library packages
$ cabal init # Interactively prompts you to set up a new project.
# Choose an executable project, rather than library.
$ echo 'main = putStrLn "Hello, world!"' > Main.hs
$ cabal run
Cabal supports "sandboxes" which isolate dependencies for each project that you work on, like virtualenv for Python, node_modules
local to the project for npm
, etc. This is strongly recommended to avoid "dependency hell" situations. Just run cabal sandbox init
and Cabal will then use the project-specific sandbox. cabal freeze
creates a cabal.config
config file with explicit dependency versions which you can check into version control for a team.
For more, read the Cabal guides or What I Wish I Knew When Learning Haskell.