learnhaskell/README.md

756 lines
29 KiB
Markdown
Raw Normal View History

2014-05-19 19:43:44 +00:00
This is my recommended path for learning Haskell.
2014-05-19 19:43:26 +00:00
2014-05-19 19:43:44 +00:00
#### Something to keep in mind: *don't sweat the stuff you don't understand immediately*. Just keep moving.
2014-07-01 00:42:21 +00:00
# Community
Our IRC channel is `#haskell-beginners` on Freenode.
IRC web client [here](http://webchat.freenode.net/).
2014-07-01 00:42:21 +00:00
2014-08-04 05:49:49 +00:00
## Community Guidelines
2014-08-04 05:42:31 +00:00
[Letter to a Young Haskell Enthusiast](http://comonad.com/reader/2014/letter-to-a-young-haskell-enthusiast/)
2014-08-04 05:49:49 +00:00
Be nice above all else!
2014-05-19 19:43:44 +00:00
# Primary course
## What are Haskell, GHC, and Cabal?
Haskell is a programming language as laid out in the reports, most recent one
being in 2010. [onlinereport](http://www.haskell.org/onlinereport/haskell2010/)
GHC is the most popular compiler for Haskell and is what you'll install along
with Cabal. Cabal is the project and dependency management tool used with
GHC. You almost definitely want both if you're going to start writing Haskell.
Cabal is equivalent to Ruby's Bundler, Python's pip, Node's NPM, Maven, etc. GHC
manages packaging itself, Cabal chooses what versions to install.
2014-05-19 19:43:44 +00:00
## Getting started
2014-07-29 04:01:52 +00:00
### Ubuntu
2014-05-19 19:43:44 +00:00
[This](http://launchpad.net/~hvr/+archive/ghc) PPA is excellent and is what I
use on all my Linux dev and build machines.
2014-05-19 19:43:44 +00:00
Specifically:
```bash
$ sudo apt-get update
$ sudo apt-get install python-software-properties # v12.04 and below
$ sudo apt-get install software-properties-common # v12.10 and above
$ sudo add-apt-repository -y ppa:hvr/ghc
$ sudo apt-get update
$ sudo apt-get install cabal-install-1.20 ghc-7.8.3 happy-1.19.4 alex-3.1.3
```
2014-05-19 19:43:44 +00:00
Then add
`~/.cabal/bin:/opt/cabal/1.20/bin:/opt/ghc/7.8.3/bin:/opt/happy/1.19.4/bin:/opt/alex/3.1.3/bin` to your PATH (bash_profile, zshrc, bashrc, etc)
2014-05-19 19:43:44 +00:00
*Optional:* You could also add `.cabal-sandbox/bin` to your path. Code that you
are actively developing will be available to you from the command line. This
only works when your current working directory is a cabal sandbox.
2014-06-23 20:19:35 +00:00
### Debian
#### GHC Repository for debian stable
If you use Debian stable, it is easier to use http://deb.haskell.org/. To use it:
- Add the line `deb http://deb.haskell.org/stable/ ./` to `/etc/apt/sources.list`
```bash
$ GET http://deb.haskell.org/deb.haskell.org.gpg-key | apt-key add - # Add the key to avoid warnings
$ sudo apt-get update
$ sudo apt-get install ghc-7.8.3 happy alex cabal-install
```
#### Using Ubuntu PPA
2014-06-23 20:19:35 +00:00
If you're not using stable, you can follow the same steps as Ubuntu, but will
have to execute an additional command. Immediately after
`sudo add-apt-repository -y ppa:hvr/ghc` is executed run:
2014-06-23 20:19:35 +00:00
```bash
sudo sed -i s/jessie/trusty/g /etc/apt/sources.list.d/hvr-ghc-jessie.list
```
For other Debian versions, just replace all occurences of "jessie" with your
version name in the command above.
2014-06-23 20:19:35 +00:00
2014-09-17 20:57:23 +00:00
If, for some reason, the file `/etc/apt/sources.list.d/hvr-ghc-jessie.list` does
not exist, then `/etc/apt/sources.list` should contain a line like this:
```
deb http://ppa.launchpad.net/hvr/ghc/ubuntu jessie main
```
Replace `jessie` with `trusty` in this line.
2014-06-23 20:19:35 +00:00
#### Manual compilation
You can follow
[this](http://www.davesquared.net/2014/05/platformless-haskell.html) guide
written for Mac OS X:
Notes:
- Set your prefix accordingly when configuring ghc.
- Instead of grabbing the `cabal-install` binary, grab the source and then run
`bootstrap.sh` script.
2014-07-18 05:19:29 +00:00
### Fedora 20
To install Haskell 7.8x from the unofficial repo (Fedora 21+ will include it in
the official one:
- Add `https://copr.fedoraproject.org/coprs/petersen/ghc-7.8/repo/fedora-20/petersen-ghc-7.8-fedora-20.repo` as petersen-ghc-7.8-fedora-20.repo
2014-07-18 05:19:29 +00:00
- `sudo yum install ghc`
2014-05-19 20:22:18 +00:00
### Arch Linux
2014-05-19 20:18:36 +00:00
To install Haskell from the official repos on Arch Linux, run
2014-05-19 20:18:36 +00:00
```bash
$ sudo pacman -S cabal-install ghc happy alex haddock
```
2014-05-19 20:18:36 +00:00
### Gentoo
On Gentoo, you can install the individual components of the Haskell Platform
through Portage. If you use `ACCEPT_KEYWORDS=arch` (as opposed to
`ACCEPT_KEYWORDS=~arch`), Portage will install ancient versions of the various
Haskell things. With that in mind, iff you use `ACCEPT_KEYWORDS=arch`, add the
following to `/etc/portage/package.keywords`.
dev-haskell/cabal-install
dev-lang/ghc
Once that is done,
```bash
$ emerge -jav dev-lang/ghc dev-haskell/cabal-install
```
Gentoo keeps a "stable" (read: old) version of `cabal-install` in the Portage
tree, so you'll want to use `cabal-install` to install the more recent
version. Note that the backslashes are intentional.
```bash
$ \cabal update # The backslashes
$ \cabal install cabal-install # are intentional
```
You have now installed cabal on a global scale with portage, and locally in your
home directory with `cabal-install`. The next step is to make sure that when you
run `cabal` in a terminal, your shell will run the up-to-date version in your
home directory. You will want to add the following lines to your shell's
configuration file:
```bash
PATH=$PATH:$HOME/.cabal/bin
alias cabal="$HOME/.cabal/bin/cabal"
```
If you don't know what your shell is, more than likely, your shell is Bash. If
you use Bash, the file you will edit is `~/.bashrc`. If you use Z-shell, the
file is `~/.zshrc`. You can run the following command to find out what your
shell is.
```bash
echo $SHELL | xargs basename
```
I use zsh, so that command outputs `zsh` when I run it.
Once you do all of that, you'll want to install the additional tools `alex` and
`happy`.
```bash
$ cabal install alex happy
```
Congratulations! You now have a working Haskell installation!
2014-05-25 08:20:59 +00:00
### Mac OS X
2014-09-30 17:15:36 +00:00
#### 10.9
Install the [GHC for Mac OS X](http://ghcformacosx.github.io/) app, which
includes GHC and Cabal. It provides instructions on how to add GHC and Cabal to
your path after you've dropped the `.app` somewhere.
2014-05-25 08:20:59 +00:00
2014-09-30 17:15:36 +00:00
#### 10.6-10.8
Do the binary distribution install described below with [this tarball](https://www.haskell.org/platform/download/2014.2.0.0/ghc-7.8.3-x86_64-apple-darwin-r3.tar.bz2).
2014-09-30 17:15:36 +00:00
2014-12-11 05:38:17 +00:00
### Windows
- The [windows minimal GHC installer](http://neilmitchell.blogspot.com/2014/12/beta-testing-windows-minimal-ghc.html)
is able to compile `network` et al. Technically in beta but should work for
the purposes of anybody reading this guide.
2014-12-11 05:38:17 +00:00
Don't forget to run the installer as administrator as it will want to install in
your Program Files.
2014-12-11 05:38:17 +00:00
### Other Linux users
2014-05-19 19:43:44 +00:00
Download the latest binary distributions for cabal and ghc:
#### GHC
[GHC](http://www.haskell.org/ghc/) is the most popular way to work in the
Haskell language. It includes a compiler, REPL (interpreter), package
management, and other things besides.
2014-05-19 19:43:44 +00:00
#### Cabal
[Cabal](https://www.haskell.org/cabal/download.html) does project management and
dependency resolution. It's how you'll install projects, typically into their
own sandbox.
2014-05-19 19:43:44 +00:00
#### Detailed manual install guide for Mac OS X
You don't need this if you use the .app, but if it doesn't work for you, try
[this](http://www.davesquared.net/2014/05/platformless-haskell.html) with the
binary distribution.
2014-05-19 19:43:44 +00:00
2014-07-02 22:10:37 +00:00
---
## [Yorgey course](http://www.seas.upenn.edu/~cis194/spring13/index.html)
2014-07-02 22:10:37 +00:00
> *Do this first*, this is the primary way I recommend being introduced to Haskell.
2014-05-19 19:43:44 +00:00
[Brent Yorgey](https://byorgey.wordpress.com)'s course is the best I've found so
far and replaces Yann Esposito's HF&H. This course is valuable as it will not
only equip you to write basic Haskell but also help you to understand parser
combinators.
2014-05-19 19:43:44 +00:00
The only reason you shouldn't start with cis194 is if you are not a programmer
or are an inexperienced one. If that's the case, start with
2015-02-10 14:13:04 +00:00
[Thompson's book](http://www.haskellcraft.com/craft3e/Home.html) and transition to cis194.
2015-02-10 14:13:04 +00:00
If you are not new to programming, [Learn You A Haskell](learnyouahaskell.com)
and [Real World Haskell](http://book.realworldhaskell.org/) are recommended
primarily as supplemental references for completing the cis194 course. RWH has
some additional material that LYAH does not that is useful to people using
Haskell in production as well.
2014-05-19 19:43:44 +00:00
2015-02-04 21:35:00 +00:00
---
## Supplementary Course [cs240h](http://www.scs.stanford.edu/14sp-cs240h/)
> Provides more material on intermediate topics
This is [Bryan O'Sullivan](https://github.com/bos)'s online course from the
class he teaches at Stanford. If you don't know who he is, take a gander at half
the libraries any Haskell application ends up needing and his name is on it. Of
particular note if you've already done the Yorgey course are the modules on
phantom types, information flow control, language extensions, concurrency,
pipes, and lenses.
---
[Learn You a Haskell for Great Good (LYAH)](http://learnyouahaskell.com) and
[Real World Haskell](http://book.realworldhaskell.org) (Thanks bos!) are
available online.
I recommend RWH as a reference (thick book). The chapters for parsing and monads
are great for getting a sense for where monads are useful. Other people have
said that they've liked it a lot. Perhaps a good follow-up for practical idioms
after you've got the essentials of Haskell down?
2014-11-14 05:47:01 +00:00
### For understanding list and fold
- [Explain List Folds to Yourself](http://vimeo.com/64673035)
2014-11-14 05:47:01 +00:00
### For learning some common typeclasses
Useful for understanding `Functor`, `Applicative`, `Monad`, `Monoid` and other
typeclasses in general but also some Hask-specific category theory:
- The [Typeclassopedia](http://www.haskell.org/haskellwiki/Typeclassopedia)
### Understanding basic Haskell error messages
- [Understanding basic error messages](http://ics.p.lodz.pl/~stolarek/_media/pl:research:stolarek_understanding_basic_haskell_error_messages.pdf)
2014-05-19 19:43:44 +00:00
## Development Environment
### Emacs
- [Alejandro Serras's tutorial](https://github.com/serras/emacs-haskell-tutorial/blob/master/tutorial.md)
2014-06-10 18:43:20 +00:00
- [My dotfiles](https://github.com/bitemyapp/dotfiles/)
2014-06-10 18:43:20 +00:00
- [Chris Done's emacs config](https://github.com/chrisdone/chrisdone-emacs)
2014-05-19 19:43:44 +00:00
### Vim
- [Vim page on haskellwiki](http://www.haskell.org/haskellwiki/Vim)
2014-12-10 10:02:47 +00:00
- [Haskell-vim-now](https://github.com/begriffs/haskell-vim-now)
2014-05-19 19:43:44 +00:00
- [A vim+haskell workflow](http://www.stephendiehl.com/posts/vim_haskell.html)
2014-05-19 19:43:44 +00:00
- [GHC-Mod](https://github.com/kazu-yamamoto/ghc-mod)
2014-05-19 19:43:44 +00:00
- [GHC-Mod vim plugin](https://github.com/eagletmt/ghcmod-vim)
2014-05-19 19:43:44 +00:00
- [Hindent](https://github.com/chrisdone/hindent)
2014-05-19 19:43:44 +00:00
### Sublime Text
- [SublimeHaskell](https://github.com/SublimeHaskell/SublimeHaskell)
2014-05-19 19:43:44 +00:00
## FAQ and working with Cabal
### Fantastic FAQ
In addition to being an amazing guide for all kinds of things such as GADTs,
this also covers some useful basics for Cabal
2014-05-31 03:34:54 +00:00
- [What I wish I knew when learning Haskell](http://dev.stephendiehl.com/hask/)
also on github [here](https://github.com/sdiehl/wiwinwlh).
2014-05-19 19:43:44 +00:00
### Cabal guidelines
Cabal Hell was a problem for Haskell users before the introduction of
sandboxes. Installing outside of a sandbox will install into your user
package-db. This is *not* a good idea except for foundational packages like
Cabal, alex, and happy. Nothing else should be installed in the user or global
package-dbs unless you know what you're doing.
2014-06-13 02:27:37 +00:00
Some best practices for avoiding cabal hell are available [here](http://softwaresimply.blogspot.com/2014/07/haskell-best-practices-for-avoiding.html).
2014-05-19 19:43:44 +00:00
To experiment with a package or start a project, begin by doing
`cabal sandbox init` in a new directory.
2014-05-19 19:43:44 +00:00
Put briefly:
- Always use sandboxes for installing new packages, building new or existing
projects, or starting experiments
2014-05-19 19:43:44 +00:00
- Use `cabal repl` to start a project-scoped ghci instance
The sandbox-based approach I suggest should avoid package-dependency problems,
but it's incompatible with the way the Haskell Platform provides pre-built
packages. If you're still learning Haskell and don't understand how ghc-pkg and
Cabal work, *avoid platform* and instead use the install instructions earlier in
the guide.
2014-06-06 21:34:00 +00:00
2014-05-19 19:43:44 +00:00
## Search code by type signature
The [Hoogle search engine](http://www.haskell.org/hoogle/) can search by type.
2014-05-19 19:43:44 +00:00
http://www.haskell.org/hoogle/?hoogle=%28a+-%3E+b%29+-%3E+%5ba%5d+-%3E+%5bb%5d
Also hosted by fpcomplete [here](https://www.fpcomplete.com/hoogle).
2014-05-19 19:43:44 +00:00
Also [Hayoo](http://holumbus.fh-wedel.de/hayoo/hayoo.html) (which has all of
hackage enabled for search by default).
2014-05-19 19:43:44 +00:00
### Setting up your own local instance of Hoogle
Take a look [here](https://gist.github.com/bitemyapp/3e6a015760775e0679bf)
2014-08-30 03:15:26 +00:00
## Haddock
1. [Fix your hackage documentation](http://fuuzetsu.co.uk/blog/posts/2014-01-06-Fix-your-Hackage-documentation.html)
2. [Hackage documentation v2](http://fuuzetsu.co.uk/blog/posts/2014-01-06-Hackage-documentation-v2.html)
2014-08-30 03:15:26 +00:00
Note that these posts are *slightly out of date*: for example, now Hackage sports
shiny new info with documentation info and build status.
2014-12-10 10:02:34 +00:00
2014-08-30 03:15:26 +00:00
### What you really need to know
In order to have haddocks include documentation for related packages, you have
to set `documentation: True` in your `~/.cabal/config`. If it was left on the
default (`False`) or set to `False`, you'll have to delete all your packages and
reinstall before generating haddocks.
2014-08-30 03:15:26 +00:00
The other thing to keep in mind is that due to the way the `$pkg` parameter gets
interpolated *by* cabal, not by you, the `html-location` and `content-location`
parameters *must be in single quotes* and entered into a shell or contained in a
shell script. They will not work in a Makefile, because it will think they are
Make variables!
2014-08-30 03:15:26 +00:00
```bash
#!/usr/bin/env sh
2014-08-30 03:15:26 +00:00
cabal haddock --hoogle --hyperlink-source --html-location='http://hackage.haskell.org/package/$pkg/docs' --contents-location='http://hackage.haskell.org/package/$pkg'
```
## What does that <- / do / list comprehension syntactic sugar do?
2014-11-21 18:31:07 +00:00
Excellent [article](http://www.haskellforall.com/2014/10/how-to-desugar-haskell-code.html).
2014-11-21 18:31:07 +00:00
2014-11-04 02:36:41 +00:00
## TravisCI
If you're as big a fan of [TravisCI](https://travis-ci.org) as I am, then I
*strongly* recommend you take a look at
[multi-ghc-travis](https://github.com/hvr/multi-ghc-travis) by as the basis of
the `travis.yml` for your Haskell projects.
2014-11-04 02:36:41 +00:00
2014-05-19 19:43:44 +00:00
## Fun Stuff
After you're comfortable with Haskell, strongly consider learning Lenses and
Prisms, even if just as a "user". You don't need to understand the underlying
category for it to be useful.
2014-05-19 19:43:44 +00:00
Look here: [Lens package on hackage](http://hackage.haskell.org/package/lens).
2014-05-19 19:43:44 +00:00
## Frontend/JavaScript
We have an embarrassment of riches! There are three main choices I would
recommend:
2014-05-19 19:43:44 +00:00
* [Haste](http://haste-lang.org/) a javascript to haskell compiler
- The [compiler](https://github.com/valderman/haste-compiler) on github.
- An excellent [demo](http://www.airpair.com/haskell/posts/haskell-tutorial-introduction-to-web-apps) of Haste with an example project
2014-06-26 18:21:23 +00:00
* [GHCJS](https://github.com/ghcjs/ghcjs)
- [GHCJS Introduction](http://weblog.luite.com/wordpress/?p=14)
- [Functional Reactive Web Interfaces with GHCJS and Sodium](http://weblog.luite.com/wordpress/?p=127)
2014-05-19 19:43:44 +00:00
* [PureScript](http://www.purescript.org/)
- Not strictly Haskell like Haste and GHCJS, but a popular choice among
Haskellers
- Written in and inspired by haskell
- Try purescript in you browser [here](http://try.purescript.org/)
- Great guide for [getting started](http://www.christopherbiscardi.com/2014/06/22/getting-started-with-purescript/)
2014-06-26 18:21:23 +00:00
2015-01-02 01:26:09 +00:00
### Which frontend language do I use?
2014-10-31 22:01:52 +00:00
GHCJS and Haste are both fully Haskell. GHCJS will work with more Haskell
packages than Haste, but this doesn't affect a lot of frontend
projects. PureScript isn't Haskell at all, so direct code sharing with your
backend will not work.
2014-10-31 22:01:52 +00:00
GHCJS has the fattest runtime payload overhead at about 100kb (luite is working
on this). Haste and PureScript are competitive.
2014-10-31 22:01:52 +00:00
PureScript has the best JS tooling integration (uses gulp/grunt/bower), GHCJS
and Haste integrate better with Haskell's tooling (Cabal).
2014-10-31 22:01:52 +00:00
All three are great choices and will work for most frontend projects.
2014-10-31 21:58:16 +00:00
2014-10-04 20:25:06 +00:00
## Parsing in Haskell
- Parser combinator [tutorial](https://github.com/JakeWheat/intro_to_parsing)
for Haskell using Parsec
2014-10-04 20:56:57 +00:00
- [Writing your own micro-Parsec](http://olenhad.me/articles/monadic-parsers/)
2014-10-04 20:56:57 +00:00
2014-10-04 20:25:06 +00:00
### Parsing and generating JSON
2014-07-25 17:46:54 +00:00
Aeson is the standard [JSON](https://json.org) parsing solution in
haskell. Available from [hackage](https://hackage.haskell.org/package/aeson) and
[github](https://github.com/bos/aeson).
2014-07-25 17:46:54 +00:00
- [Parsing JSON using Aeson](http://blog.raynes.me/blog/2012/11/27/easy-json-parsing-in-haskell-with-aeson/)
2014-07-25 17:46:54 +00:00
- [Aeson and user created types](http://bitemyapp.com/posts/2014-04-11-aeson-and-user-created-types.html)
2014-07-25 17:46:54 +00:00
- [Parsing non-deterministic data with aeson and sum types](http://bitemyapp.com/posts/2014-04-17-parsing-nondeterministic-data-with-aeson-and-sum-types.html)
- [Aeson tutorial](https://www.fpcomplete.com/school/starting-with-haskell/libraries-and-frameworks/text-manipulation/json)
2014-07-25 17:46:54 +00:00
## Laziness, strictness, guarded recursion
- Marlow's [book](http://chimera.labs.oreilly.com/books/1230000000929/ch02.html)
about parallelism and concurrency has one of the best introductions to
laziness and normal form I've found. Use other material too if it doesn't
stick immediately.
2014-06-09 21:04:35 +00:00
- [More points for lazy evaluation](http://augustss.blogspot.hu/2011/05/more-points-for-lazy-evaluation-in.html)
- [Oh my laziness!](http://alpmestan.com/posts/2013-10-02-oh-my-laziness.html)
- SO question '[Does haskell have laziness?](http://stackoverflow.com/questions/13042353/does-haskell-have-tail-recursive-optimization)'
2014-06-21 17:44:08 +00:00
- [Johan Tibell](https://github.com/tibbe)'s slides from a talk on
[reasoning about laziness](http://www.slideshare.net/tibbe/reasoning-about-laziness).
2014-06-09 21:04:35 +00:00
2014-07-13 22:44:18 +00:00
### For a more thorough understanding of laziness, NF, WHNF
- [Notes on lambda calculus](https://vec.io/posts/notes-on-lambda-calculus).
#### Research papers about lazy lambda calculi
2014-07-13 22:44:18 +00:00
- [A call by need lambda calculus](http://homepages.inf.ed.ac.uk/wadler/topics/call-by-need.html#need-journal).
2014-07-13 22:44:18 +00:00
- [Demonstrating Lambda Calculus Reduction](http://www.itu.dk/~sestoft/papers/sestoft-lamreduce.pdf)
2014-07-13 22:44:18 +00:00
- [The lazy lambda calculus](http://www.cs.ox.ac.uk/files/293/lazy.pdf).
2014-07-13 22:44:18 +00:00
### Brief demonstration
```haskell
let a = 1 : a -- guarded recursion, (:) is lazy and can be pattern matched.
2014-06-05 22:42:40 +00:00
let (v : _) = a
> v
1
> head a -- head a == v
1
let a = 1 * a -- not guarded, (*) is strict
> a
*** Exception: <<loop>>
```
- [Lazy evaluation of Haskell](http://www.vex.net/~trebla/haskell/lazy.xhtlm)
2014-06-09 21:04:35 +00:00
2014-05-19 19:43:44 +00:00
## Parallelism/Concurrency
- [Parallel and Concurrent Programming in Haskell](http://chimera.labs.oreilly.com/books/1230000000929). This book by Simon Marlow is probably the best I've ever read on the topics of Parallelism and Concurrency.
2014-05-19 19:43:44 +00:00
- A thorough [walk-through](http://kukuruku.co/hub/haskell/haskell-testing-a-multithread-application) on testing & incremental development of a multi-threaded application in Haskell
- [Functional Reactive Programming](http://www.haskell.org/haskellwiki/Functional_Reactive_Programming)
2014-05-19 19:43:44 +00:00
## Lenses and Prisms
People vastly overestimate the difficulty of using Lens. Anybody comfortable
with Functor/Foldable/Traversable (or even just the first one) can leverage
lenses and prisms to make their life happier.
2014-05-19 19:43:44 +00:00
If you've ever done something like: `(fmap . fmap)` you were "lensing" in your
head.
2014-05-19 19:43:44 +00:00
I recommend these two tutorials/introductions:
- [A little lens starter tutorial](https://www.fpcomplete.com/school/to-infinity-and-beyond/pick-of-the-week/a-little-lens-starter-tutorial)
2014-05-19 19:43:44 +00:00
- [Lens: Lenses, Folds and Traversals](https://github.com/ekmett/lens#lens-lenses-folds-and-traversals)
2014-05-19 19:43:44 +00:00
2014-08-20 22:34:30 +00:00
## Monads and monad transformers
2014-06-30 22:47:01 +00:00
### Do not do these until you understand typeclasses, Monoid, Functor, and Applicative!
Implement the standard library monads ( List, Maybe, Cont, Error, Reader,
Writer, State ) for yourself to understand them better. Then maybe write an
monadic interpreter for a small expression language using
[Monad Transformers Step by Step](http://www.cs.virginia.edu/~wh5a/personal/Transformers.pdf)
paper (mentioned in 'monad transformers' below).
2014-06-30 22:47:01 +00:00
Writing many interpreters by just changing the monad to change the semantics can
help convey what's going on.
2014-06-30 22:47:01 +00:00
- [This talk](https://vimeo.com/73648150) by Tony excellently motivates monad
transformers.
2014-06-30 22:47:01 +00:00
Also, reimplement `Control.Monad`. Functions like `mapM` or `sequence` are good
opportunities to practice writing generic monadic code.
2014-06-30 22:47:01 +00:00
The NICTA course can be used as a guide to this process, which will also involve
writing your own Applicative as well.
2014-07-17 20:37:46 +00:00
Credits:
2014-07-17 20:37:46 +00:00
- Reddit comment by htmltyp and Crandom [here](http://www.reddit.com/r/haskell/comments/29eke6/basic_program_ideas_for_learning_about_monads/cik5aj6).
2014-07-17 20:37:46 +00:00
- Reddit comment by jozefg [here](http://www.reddit.com/r/haskell/comments/29eke6/basic_program_ideas_for_learning_about_monads/cik5trg).
2014-10-16 20:00:51 +00:00
### Monad transformers
2014-10-16 20:00:51 +00:00
- [A gentle introduction to Monad Transformers](https://github.com/kqr/gists/blob/master/articles/gentle-introduction-monad-transformers.md).
2014-10-16 20:00:51 +00:00
- [Monad transformers step-by-step](http://www.cs.virginia.edu/~wh5a/personal/Transformers.pdf) (warning, code out of date).
## Testing, tests, specs, generative/property testing
- This [tutorial](https://github.com/kazu-yamamoto/unit-test-example/blob/master/markdown/en/tutorial.md) by Kazu Yamamoto is fantastic.
- [Simple-Conduit](https://github.com/jwiegley/simple-conduit): Good simple
library for learning how streaming IO works in general, knowledge
transferrable to libraries like Pipes and Conduit
2014-07-25 17:46:54 +00:00
## Recursion Schemes
Some of the crazy \*-morphism words you've heard are actually about
recursion. NB - before tackling this material you should know how to implement
foldr for lists and at least one other data structure, such as a tree. (folds
are catamorphisms) Knowing how to implement an unfold (anamorphism) for the same
will round things out a bit.
2014-07-25 17:46:54 +00:00
This material dovetails with traversable and foldable.
- [An introduction to recursion schemes](http://patrickthomson.ghost.io/an-introduction-to-recursion-schemes/)
2014-07-25 17:46:54 +00:00
- [Don't fear the cat](http://fho.f12n.de/posts/2014-05-07-dont-fear-the-cat.html) -
Good demonstration of how hylomorphism is the composition of cata and ana.
2014-07-25 17:46:54 +00:00
- [Recursion Schemes](http://comonad.com/reader/2009/recursion-schemes/) - This
field guide is excellent.
2014-07-25 17:46:54 +00:00
- [Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire](http://eprints.eemcs.utwente.nl/7281/01/db-utwente-40501F46.pdf)
2014-07-25 17:46:54 +00:00
- [Catamorphisms](https://www.fpcomplete.com/user/edwardk/recursion-schemes/catamorphisms)
2014-07-25 17:46:54 +00:00
2014-05-19 19:43:44 +00:00
## Type and Category Theory (*not* needed to actually write Haskell, just for those interested!)
If you want to follow up on the type and category theory:
- [Catster's Guide](http://byorgey.wordpress.com/2014/01/14/catsters-guide/) and
[Catster's Guide 2](http://byorgey.wordpress.com/catsters-guide-2/)
2014-06-23 23:38:26 +00:00
- [Harper's Practical Foundations for Programming Languages](http://www.cs.cmu.edu/~rwh/plbook/book.pdf) is the best PL focused intro to type theory I've read.
2014-05-19 19:43:44 +00:00
- [Quora Question: What is the best textbook for category theory?](http://www.quora.com/Category-Theory/What-is-the-best-textbook-for-Category-theory?share=1) Kmett's recommendations
- The [haskell wikibook](http://en.wikibooks.org/wiki/Haskell/Category_theory)
has nice diagrams
2014-05-19 19:43:44 +00:00
- [Category Theory](http://www.haskell.org/haskellwiki/Category_theory) on
haskellwiki, also has good links to other resources
2014-05-19 19:43:44 +00:00
- [Categories from scratch](http://science.raphael.poss.name/categories-from-scratch.html), Includes some practical examples.
2014-05-25 12:09:02 +00:00
- [Awodey](http://ukcatalogue.oup.com/product/9780199237180.do) and
[MacLane](http://www.amazon.com/Categories-Working-Mathematician-Graduate-Mathematics/dp/0387984038). The standard textbooks on category theory.
2014-05-19 19:43:44 +00:00
- [Type theory and Functional Programming](http://www.cs.kent.ac.uk/people/staff/sjt/TTFP/).
2014-05-19 19:43:44 +00:00
- Pierce's [Great Works in PL](http://www.cis.upenn.edu/~bcpierce/courses/670Fall04/GreatWorksInPL.shtml) list.
2014-06-03 11:24:43 +00:00
### Stephen's Nifty "How to get to monad" posts
Didn't know where else to put these:
- [Adjunctions](http://www.stephendiehl.com/posts/adjunctions.html).
- [Monads](http://www.stephendiehl.com/posts/monads.html).
2014-06-20 15:29:04 +00:00
## Parametricity, ad-hoc vs. parametric polymorphism, free theorems
- [Parametricity](tony_parametricity.pdf).
2014-06-20 15:29:04 +00:00
- [TeX sources](https://github.com/tonymorris/parametricity/) for the
above talk.
2014-05-19 19:43:44 +00:00
- [Making ad-hoc polymorphism less ad-hoc](http://swizec.com/blog/week-20-making-ad-hoc-polymorphism-less-ad-hoc/swizec/6564).
2014-05-19 19:43:44 +00:00
- [Theorems for Free!](http://ttic.uchicago.edu/~dreyer/course/papers/wadler.pdf).
2014-05-19 19:43:44 +00:00
2014-06-04 20:34:47 +00:00
## Initial and Final, DSLs, Finally Tagless
- [Final Encodings, Part 1: A Quick Demonstration](http://creativelad.wordpress.com/2013/11/28/final-encodings-part-1-a-quick-demonstration/).
2014-07-20 05:38:21 +00:00
- [Transforming Polymorphic Values](http://martijn.van.steenbergen.nl/journal/2009/10/18/transforming-polymorphic-values/).
2014-06-04 20:34:47 +00:00
- [GADTs in Haskell 98](http://martijn.van.steenbergen.nl/journal/2009/11/12/gadts-in-haskell-98/).
2014-06-04 20:34:47 +00:00
- [Typed Tagless-Final Linear Lambda Calculus](https://www.fpcomplete.com/user/mutjida/typed-tagless-final-linear-lambda-calculus).
2014-06-04 20:34:47 +00:00
- [Typed tagless-final interpretations: Lecture notes](http://okmij.org/ftp/tagless-final/course/course.html).
2014-06-04 20:34:47 +00:00
- [Typed Tagless Final Interpreters](http://okmij.org/ftp/tagless-final/course/lecture.pdf).
2014-06-04 20:34:47 +00:00
- [The dog that didn't bark](http://existentialtype.wordpress.com/2011/03/21/the-dog-that-didnt-bark/) less specifically relevant but interesting.
2014-06-04 20:34:47 +00:00
2014-06-03 11:24:43 +00:00
## Comonads
- [Comonads in Haskell](https://speakerdeck.com/dmoverton/comonads-in-haskell).
2014-06-03 11:24:43 +00:00
- [SO question: Can a Monad be a Comonad](http://stackoverflow.com/questions/16551734/can-a-monad-be-a-comonad).
2014-06-03 11:27:42 +00:00
2014-06-03 11:24:43 +00:00
## Yoneda / CoYoneda
- [SO question: Step-by-step explanation of coyoneda](http://stackoverflow.com/questions/24000465/step-by-step-deep-explain-the-power-of-coyoneda-preferably-in-scala-throu).
2014-06-03 11:24:43 +00:00
- Free monads for Less, a sequence of three articles by Edward Kmett
* [Part 1: Codensity](http://comonad.com/reader/2011/free-monads-for-less/).
* [Part 2: Yoneda](http://comonad.com/reader/2011/free-monads-for-less-2/).
* [Part 3: Yielding IO](http://comonad.com/reader/2011/free-monads-for-less-3/).
2014-08-25 19:41:47 +00:00
## IO
- [Evaluation order and State tokens](https://www.fpcomplete.com/user/snoyberg/general-haskell/advanced/evaluation-order-and-state-tokens)
2014-08-25 19:41:47 +00:00
Comment from Reddit thread by `glaebhoerl`
Interesting side note: GHC needs to hide the state token representation behind
an abstract IO type because the state token must always be used linearly (not
duplicated or dropped), but the type system can't enforce this. Clean, another
lazy Haskell-like language, has uniqueness types (which are like linear types
and possibly different in ways I'm not aware of), and they expose the
World-passing directly and provide a (non-abstract) IO monad only for
convenience.
2014-08-25 19:42:08 +00:00
- [Unraveling the mystery of the IO monad](http://blog.ezyang.com/2011/05/unraveling-the-mystery-of-the-io-monad/).
2014-08-25 19:41:47 +00:00
- [First class "statements"](http://blog.jle.im/entry/first-class-statements).
2014-08-25 19:41:47 +00:00
- [Haddocks for System.IO.Unsafe.unsafePerformIO](http://hackage.haskell.org/package/base-4.7.0.1/docs/System-IO-Unsafe.html#v:unsafePerformIO)
Read the docs and note implementation of unsafeDupablePerformIO
2014-08-25 19:41:47 +00:00
2014-07-23 19:54:01 +00:00
## GHC Core and performance tuning
2014-07-23 20:35:12 +00:00
- [Write Haskell as Fast as C](write_haskell_as_fast_as_c.md)
2014-07-23 19:54:01 +00:00
- [GHC Wiki: CoreSyn Type](https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/CoreSynType).
2014-07-23 19:54:01 +00:00
- [Hackage: GHC Core](https://hackage.haskell.org/package/ghc-core).
2014-07-23 19:54:01 +00:00
- [SO Question: Reading GHC Core](http://stackoverflow.com/questions/6121146/reading-ghc-core).
2014-07-23 19:54:01 +00:00
- [Haskell as fast as C](http://donsbot.wordpress.com/2008/06/04/haskell-as-fast-as-c-working-at-a-high-altitude-for-low-level-performance/).
2014-07-23 19:54:01 +00:00
- [Real World Haskell, Chapter 25: Profiling and Optimizations](http://book.realworldhaskell.org/read/profiling-and-optimization.html).
2014-07-23 19:54:01 +00:00
2014-06-03 11:24:43 +00:00
## Dependent typing
- [Grokking sum types, value constructors, and type constructors](http://bitemyapp.com/posts/2014-04-05-grokking-sums-and-constructors.html) squint hard.
2014-06-03 11:24:43 +00:00
- [Lightweight Dependent-type Programming](http://okmij.org/ftp/Computation/lightweight-dependent-typing.html).
2014-06-03 11:24:43 +00:00
- [Idris programming language](http://www.idris-lang.org/).
2014-06-03 11:24:43 +00:00
2014-06-26 20:48:47 +00:00
## Propositions vs. Judgments (computation)
- [StackExchange question: What is the difference between propositions and judgements](http://cstheory.stackexchange.com/questions/9826/what-is-the-difference-between-propositions-and-judgments).
2014-06-26 20:48:47 +00:00
- [Lecture notes from a short, three lecture course](http://www.ae-info.org/attach/User/Martin-L%C3%B6f_Per/OtherInformation/article.pdf)
2014-06-26 20:48:47 +00:00
2014-09-22 03:43:11 +00:00
## Graph algorithms and data structures
- The [fgl package](https://hackage.haskell.org/package/fgl) particularly the shortest path algos [here](http://hackage.haskell.org/package/fgl-5.4.2.2/docs/Data-Graph-Inductive-Query-SP.html) which are pure.
2014-09-22 03:43:11 +00:00
- [Inductive graphs and Functional Graph Algorithms](http://web.engr.oregonstate.edu/~erwig/papers/abstracts.html#JFP01).
2014-09-22 03:43:11 +00:00
- [FGL/Haskell - A Functional Graph Library](http://web.engr.oregonstate.edu/~erwig/fgl/haskell/old/fgl0103.pdf).
2014-09-22 03:43:11 +00:00
- [Data.Graph source from Containers package](http://hackage.haskell.org/package/containers-0.5.5.1/docs/Data-Graph.html).
2014-09-22 03:43:11 +00:00
- The [graphs package](https://hackage.haskell.org/package/graphs).
2014-09-22 03:43:11 +00:00
- [SO question about PHOAS](http://stackoverflow.com/questions/24369954/separate-positive-and-negative-occurrences-of-phoas-variables-in-presence-of-rec)
2014-09-22 03:43:11 +00:00
- [PHOAS for free](https://www.fpcomplete.com/user/edwardk/phoas).
2014-09-22 03:43:11 +00:00
- [Tying the Knot](http://www.haskell.org/haskellwiki/Tying_the_Knot).
2014-09-22 03:43:11 +00:00
2015-02-10 14:13:04 +00:00
- [Hackage: dag](https://hackage.haskell.org/package/dag).
2015-01-24 04:25:41 +00:00
## Extended Reading list (some are already included here)
2014-05-19 19:43:44 +00:00
- [Essential Haskell Reading List](http://www.stephendiehl.com/posts/essential_haskell.html)
2014-07-29 04:06:27 +00:00
2014-10-07 19:09:48 +00:00
## Stackage
For any users (usually Yesod users) that have build problems, consider Stackage.
- A good summary of Stackage is
[here](https://www.fpcomplete.com/blog/2014/05/stackage-server).
2014-10-07 19:09:48 +00:00
In the author's opinion, Stackage is usually more useful than `cabal freeze`.
2014-07-29 04:06:27 +00:00
## Dialogues
[Dialogues](dialogues.md) these are actually pretty important and helpful. Look
here for deep dives on a variety of topics.