Ask HN: What resources do you recommend for learning Haskell?
What resources do you recommend for learning Haskell?
I am working my way through “Learn You a Haskell for the greater good”
I also have a side project to learn things by doing, but was wondering what the most recommended learning sources were which people found very useful.
66 comments
[ 3.1 ms ] story [ 121 ms ] threadTo be clear it's also for learning, but I'm wondering what else is there outside of the Haskell/PureScript etc. world.
Servant[1] allows you to create type-safe APIs, and there are many libraries that allow you to define your HTML in a type-safe way.
The Haskell wiki lists some other frameworks: https://wiki.haskell.org/Web/Frameworks
[1] https://hackage.haskell.org/package/servant
The first chapter is about Lambda Calculus which is kind of a Haskell meme at this point, but learning it actually did help me a lot to grok how Haskell programs are meant to fit together.
Other than that, just doing some basic side projects and leaning about how to use Cabal effectively should get you there.
In Haskell, when you don't understand some detail it really comes back to get you. I read LYaH and I felt like I understood the big picture, but I didn't understand that it was critical to understand the types of _everything_ in an expression that I wrote. (My own failing.)
In summary: I highly recommend. https://HaskellBook.com
My background when I read it: 10+ years programming, 5+ years functional programming, 2 attempts reading LYaH (1 successfully). I still loved it. It would have saved me a lot of grief to start with the HB instead of LYaH.
Functional Programming in Haskell https://youtube.com/playlist?list=PLF1Z-APd9zK7usPMx3LGMZEHr...
For further self-learning, it might be interesting to learn about the underlying mathematical concepts, such as category theory. A deep dive into the workings of a Hindley–Milner type system might also help demystify some of Haskell's typing magic.
[1] https://haskellbook.com/
https://wiki.haskell.org/H-99:_Ninety-Nine_Haskell_Problems
I liked Haskell Programming from First Principles as well — read it later on to fill in some gaps.
After that, I honestly think you'll get the best bang-for-buck by reading library-specific tutorials. If you play with enough of the libraries the rest of the language more or less falls into place.
Conduit is a pretty ok streaming library, and has good documentation: https://github.com/snoyberg/conduit#readme
Lens gives you a lot of useful features that more or less correspond to stuff like Getters and Setters in something like Java, and the tutorials for it get into some helpful details about writing Haskell code: https://hackage.haskell.org/package/lens
Otherwise it's basically a lot of "just build shit, and don't be afraid to feel confused" and it'll fall into place.
https://m.youtube.com/watch?v=nlTJU8wLo7E
[0]: https://github.com/hmemcpy/milewski-ctfp-pdf
[1]: https://aphyr.com/posts/342-typing-the-technical-interview
Haskell != Category Theory. You don't have to know what an Endofunctor is in order to write useful programs. Haskell is just another programming language. It's totally possible to do cool stuff in it without knowing any of the theories that back a lot of the "why" behind its common abstractions.
Pick up any book and just start building toy programs! Don't over think it. Start very small. Make a CLI tool. Scrape some data off the internet. Even simple haskell programs will cause you to bump into all kinds of concepts at the time you need to learn them.
Just working through a book can make Haskell seem painfully esoteric. Monad transformers broke my brain when I tried to learn them simply because I reached the monad transformer chapter. However, I finally "got" them once I was actually building something, because their existence is something you naturally start to bump into the more you program. There's a friction that comes from no having them, but noticing that "friction" and letting it guide you can only happen over time as you use the language.
I'm not sure why, but the Haskell one clicks for me more than some of their other guides.
This isn't a great way to learn Haskell, but it's enough to start writing working code (and writing working code is a good way to learn!!)
I successfully taught dozens of people who had no former functional background. Just did a weekly meeting covering the lecture and prior week’s homework.
https://www.cis.upenn.edu/~cis1940/spring13/lectures.html
Straightforward and short. Takes you to the interesting bits very quickly.
[0] https://smunix.github.io/dev.stephendiehl.com/hask/index.htm...
[1] https://github.com/sdiehl/wiwinwlh
[2] https://hoogle.haskell.org/
I find Haskell very useful for my projects, but to achieve this I restrict myself to the basic subset of the language (Haskell 2010, no fancy extensions such as type families or GADTs) and use few libraries aside from the core libraries. New features and libraries always carry a high learning curve in Haskell and less popular libraries can be buggy. Instead, you will often be more productive just writing the required functionality from scratch (and it will teach you more too!).
At Jane Street, I saw my coworkers learn functional programming in just one week. (some still struggled with monads in the second week -- if that is you, I can recommend Phil's paper: https://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/b...). If you are learning Haskell in your free time and with no one experienced to help, it will obviously take you longer. If you have questions, feel free to post on the Haskell IRC or Reddit. Just don't worry that you need to read another tutorial before getting started :)
But in easily digestible terms, it's a way to narrow your view over a collection to a subset that satisfies some property, and perhaps perform some operations on that subset.
This video presentation (with a very humorous audience dynamic, might I add) serves as a great introduction by example: https://youtube.com/watch?v=QZy4Yml3LTY
basically every code base out there could use more functional effort - simple data structures and simple functions that operate on these to return a brand new structure.
With Haskell came new principles which had immediately obvious value - "is your function well-defined over all possible inputs?" and "does it always produce the same output given the same input?".
I later 'got' that first set of principles, but I mostly disagree with them.
My day job has always involved looking at exceptions and logs, figuring out "how something went wrong", and then trying to fix it. Guess which set of principles helps me make software that typically "just works".
Obviously, Haskell being an academic language helps here, since novel ideas lead to papers and boring old ideas don't.
[0]: That is statically typed lazy functional programming.
There’s no midterm in eight weeks; no final grade after that, and nobody who matters cares how good or bad you are at Haskell. Like most things, it’s not worth having an opinion about.
Give yourself permission to write Haskell poorly because that makes it more likely you will write Haskell. Give yourself permission to not learn Haskell because maybe you like the idea of writing Haskell more than the work of learning Haskell…
…yep, time and permission are the best resources for learning Haskell (or anything else as an adult). It really doesn’t matter what book you pick. Either you enjoy committing or you don’t. Either the work feels satisfying while doing the work or doesn’t.
When the work is truly satisfying, it doesn’t need to be optimized against imagined external opinions. You just do it because it is what you do.
Or not. Good luck.
https://www.youtube.com/watch?v=3VQ382QG-y4
https://www.youtube.com/watch?v=pAnLQ9jwN-E
I now refer people to “Effective Haskell” by Rebecca Skinner[0]. It’s well written, modern (published in 2023) and goes into everything you need to know to use haskell in common, real world tasks.
[0] https://pragprog.com/titles/rshaskell/effective-haskell/
I don't know what state of the art is nowadays for learning Haskell, I started my journey more than 10 years ago, but for help I recommend https://discourse.haskell.org/ whenever you feel stuck, have questions; instead of SO/subreddit.
edit: while Copilot, or equivalent, will hallucinate APIs that don't exist, I recommend having such a thing enabled as it will help you with syntax / standard library functions early on.
Also take a good look at the base, containers, directory, filepath, etc packages documentation. These come as part of the standard installation (with something like ghcup), and represent the "standard library" you have access to (on paper that would be only limited to base). For a full list of installed packages you can always run `ghc-pkg list` and start browsing the generated documentation on hackage.haskell.org