Learning Haskell in 2017
Table of Contents
- 1. Learning Haskell in 2017
- 1.1. Preface
- 1.2. Tooling
- 1.3. Random Notes
- 1.4. Resources
- 1.5. Books
- 1.6. Video introductions
- 1.7. Package troubleshooting
- 1.8. Errors
- 1.9. Meta - About this document
- 2. Bibliography
1 Learning Haskell in 2017
This is some notes from when I was learning Haskell in 2017.
The main three tools for most general Haskell development, are GHC, Stack and Cabal.
stack.yaml is the
Here's a typical scenario:
stack new foo cd foo # ... edit files .. # .. edit foo.cabal to add dependencies stack ghci # do REPL interaction stack build # build project stack test # run your unit tests stack install # install your binary
1.2.4 Other tools
- Editor integration - Emacs
- works with company-mode autocompletion
- has on-the-fly type-checking (flycheck)
- Haskell-mode – installing this mode enables haskell mode for haskell files.
It contains multiple modes though, see C-h f haskell-mode for more info. flycheck, hlint
haskell-doc-mode(the later depends on the former being active).
Git is a commonly used version control system. Specificially for developing Haskell in git repositories, you might want to consider adding some files to .gitignore
echo '.stack-work/' >> .gitignore.
1.3 Random Notes
1.3.1 Points of confusion
- Version information
import Paths_pkgname (version)Add
Paths_yourpackagenameto yourpackagename.cabal other-modules.
1.4.1 Comprehensive articles - reference material
- WHAT I WISH I KNEW WHEN LEARNING HASKELL, Stephen Diehl (@smdiehl ), updated (as of writing) March 2016.
1.4.2 Online course
- CIS194 Spring 2014, Brent Yorgey is a praised Haskell course. Yorgey has much experience developing freely available Haskell code (see e.g. the diagrams library and typeclassopedia).
The most commonly mentioned, and freely available Learn You a Haskell for Great Good by Miran Lipovača is a popular choice among beginners. A somewhat dated but much respected book for intermediate Haskell programmers is Real World Haskell by Bryan O'Sullivan, Don Stewart, and John Goerzen.
1.6 Video introductions
- Haskell Amuse-Bouche, Gogole Tech tach: https://www.youtube.com/watch?v=b9FagOVqxmI
1.7 Package troubleshooting
A dependency package broke during compilation, to fix (with cabal) use "cabal get", fix the error and
foo bar baz
<jmnoz> Can anyone recommend me a "good enough" way to (as a beginner) do error handling / exceptions for my command line tool which does a bunch of IO? [20:53] <monochrom> yes, we can recommend three ways <Tuplanolla> By "we" he means monochrom. [20:54] <EvanR> polychrom <EvanR> press B to stop evolution <monochrom> yes, we are King Monochrom <niez> hi, I have problems with latest groundhog and groundhog-utils (both from latest git commit), I get: 'Not in scope: type constructor or class ‘PhantomDb’' when building groundhog-utils (I'm building with stack using lts-7.10 resolver - which includes ghc-8.0.1), anyone can help? <lyxia> jmnoz: just return Either String values [20:55] <EvanR> you can use IO exceptions [20:56] <EvanR> :t throwIO <lambdabot> Exception e => e -> IO a <hpc> :t bracket <lambdabot> IO a -> (a -> IO b) -> (a -> IO c) -> IO c <hpc> bracket action handler finalizer [20:57] <hpc> or something like that <EvanR> setup handler body teardown [20:58] <EvanR> oh theres only 3 args <hpc> setup handler body, i suppose <EvanR> no finalizer <jmnoz> thanks folks. I got confused reading about eitherT, exceptT and so forth <hpc> jmnoz: you may find yourself writing repetitive exception handling code, and then those types will make all the sense in the world [20:59] <jmnoz> hpc: do you have any public code which you can recommend inspecting? [21:00] <hpc> but yeah, it takes perspective or just staring at stuff that