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.
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 :)
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.
To summarize, you could say that Haskell is not really made of one piece, but is something like a 34 year old, very messy academic playground.
So it might be helpful to switch to a purely functional alternative, Purescript/Elm/Gren for practical programming, or Idris/Agda to explore the more academic side.
[0] https://smunix.github.io/dev.stephendiehl.com/hask/index.htm...
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.
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/
Functional Programming in Haskell https://youtube.com/playlist?list=PLF1Z-APd9zK7usPMx3LGMZEHr...
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.
Haskell is so different from all the languages people tend to learn so it feels much like learning to code all over again. That being said, it's totally worth it! I'm a much better developer (in any language) thanks to all the wonderful things haskell has taught me. I'm much better at designing clean abstractions, I have more tools for solving problems, I have more fun coding, and new challenges don't scare me so much because I know I just need to go through the process and I'll come out the other side even better.
To answer your question, there was no one resource that worked for me. It was just a matter of time and effort going through lots of resources until one day my brain had established new neural connections and things clicked. I read several books and watched lots of people writing haskell and explaining the new (to me) concepts on twitch and youtube.
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.
When I was in college I read through Haskell Programming From First Principles. My prior programming experience (of probably ~10ish years, as a hobbyist) was mostly C++, Java and PHP.
I found it grueling. I really was just not used to reading definitions like
newtype State s a = State { runState :: s -> (a, s) }
instance Monad (State s) where
return x = State $ \s -> (x,s)
(State h) >>= f = State $ \s -> let (a, newState) = h s
(State g) = f a
in g newState
Nowadays, such a definition (and its practical applications) seems very trivial, but at the time I remember it felt like learning a new type of math, or a new language. Most of my time reading that book was spent struggling to figure out how the types fit together and why they were useful and/or necessary to be structured the way they were.This wasn't the book's fault - I actually think the book does go to great lengths to try to guide the reader gradually toward understanding. My brain just wasn't ready for it. It took a long time of playing around with Haskell, as well as playing around with other languages (and seeing things like async-await and thinking to myself "hey! that's a monad!") before these things became second nature. I think it just goes to the concept of "osmosis" in psychology - sometimes you subconsciously absorb information over time before it starts to make sense.
Dunno if this comment constitutes "advice" per se, lol. Just offering you something to relate to, I guess.
[0]: https://github.com/hmemcpy/milewski-ctfp-pdf
[1]: https://aphyr.com/posts/342-typing-the-technical-interview
Andres Loeh has recently released a pretty comprehensive introductory series there and in addition they have a fortnightly stream "The Haskell Unfolder" where they go over some more advanced subjects with examples.
Get Programming With Haskell by Will Kurt. Made up of small lessons that all build on top of each other and will really help you understand what's going on.
I wanted to like Effective Haskell but honestly didn't. YMMV.
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
If you like videos: https://www.youtube.com/results?search_query=haskell
The haskell matrix room and (slightly less useful for beginners) IRC channel: https://www.haskell.org/community
Curated resources:
https://www.extrema.is/articles/haskell-books
It's a structured, has a lot of excercises and so far (I am on Lecture 5 at the moment) very clear. It wont make you an expert, but will get you writing code quickly.
Those who learn well from a text resource, Haskell MOOC from mooc.fi [2] is pretty good.
[0]: https://www.cs.nott.ac.uk/~pszgmh/pih.html
That course takes you into coding from scratch "bind" and "return" for several use-cases, and do a bit of currying. Very interesting small exercises.
https://github.com/MostlyAdequate/mostly-adequate-guide/rele...
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!!)
This helped a bunch with getting good at higher order functions and recursion.
I took a detour to lisp after and never looked back, but that's due to my type system preferences, you'll benefit from puzzles either way.
To be clear it's also for learning, but I'm wondering what else is there outside of the Haskell/PureScript etc. world.
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.
Source: I’ve been using Haskell for fun and profit on and off since 2004
Haskell
Books:
- Maybe Haskell by Pat Brisbin [https://thoughtbot.gumroad.com/l/maybe-haskell]: Very good book, available under a "pay what you want" model (or free pdf here [https://books.thoughtbot.com/books/maybe-haskell.html]).
- Learn you a Haskell for Great Good by Miran Lipvača: Available to read online for free [http://www.learnyouahaskell.com/].
- Real World Haskell by Bryan O'Sullivan, Don Stewart, and John Goerzen: Available to read online for free [http://book.realworldhaskell.org/read/].
Online tutorials:
- List of resources on haskell.org
- Haskell Wiki [https://wiki.haskell.org/Haskell]
- The Basics of Haskell series [https://www.schoolofhaskell.com/school/starting-with-haskell...] by Bartosz Milewski, from the School of Haskell website [https://www.schoolofhaskell.com/] (which also contains a number of other great resources on Haskell more generally).
- The Haskell Phrasebook [https://typeclasses.com/phrasebook]: a free quick-start Haskell guide comprised of a sequence of small annotated programs. It stands out from more traditional Haskell tutorials in that, instead of using the principles of Functional Programming as the theoretical starting point from which to start introducing the motivation and syntax of Haskell as a programming language, instead, it introduces Haskell syntax directly using code snippets that mimic traditional imperative programming as much as possible. This is intended to help users coming from imperative languages familiarise themselves with Haskell syntax first, and then slowly build on that by using progressively more idiomatic Haskell code, motivating its suitability for Functional Programming.
Other:
- The Hoogle Search Engine [https://hoogle.haskell.org/]; search for haskell operators or expressions here to get information on them. Good for looking up functions and operators defined in the Prelude (the haskell standard library) and other modules.
- List of haskell reserved symbols and keywords with brief description / explanations [https://wiki.haskell.org/Keywords].