Among major programming languages, there are probably none that feel scarier for beginners than Haskell. And some years ago, it was so for a reason.
I first attempted to learn Haskell in 2017 and failed miserably. There were several causes: me not being very experienced with programming, a lack of materials that would fit my learning style, and the confusing Haskell ecosystem.
But I can happily say that learning Haskell has become much easier now due to work done by the community on improving the learning resources and ecosystem.
If you want to learn Haskell and finally understand what people mean by monads in all those Hacker News comments, itâs possible. To help you, Iâve put together a list of best Haskell beginner resources along with short descriptions of them.
đ€ Why learn Haskell?
âA language that doesnât affect the way you think about programming is not worth knowing.â â Alan Perlis
Learning Haskell has many benefits. Itâs a decent general-purpose language, and there are some areas such as blockchain and fintech where Haskell and other typed FP languages are frequently used.
At the same time, you have to understand that Haskell is neither extremely popular nor widely demanded in the job market. Especially for Haskell juniors, it can be hard to find a position writing Haskell.
Therefore, I think the most significant benefit of learning a language like Haskell is that youâll expand your horizon and become a better programmer. The concepts you learn in Haskell will help you write better code in other programming languages, even in conventional ones like JavaScript, Python, or Ruby.
đșïž How to learn Haskell?
First step: close that monad tutorial. đ
Hereâs what I would do:
- To begin, watch one of the courses listed in the course section of this article to get a feel for the language.
- After that, you can use one of the books Iâve listed to structure your learning process.
- At the same time, start building your own projects (CLI todo tool, web server) or doing exercises in Exercism or CodinGame.
- Keep increasing your knowledge, looking up things you need for your projects, and building small applications to test what you learn.
- If all works out well, you should be able to do basic tasks with Haskell. Then, you can turn to resources like Haskell in Depth or just explore the areas of Haskell that interest you by reading blog posts and talking to other Haskellers.
đ Best Haskell books
For your first book, I suggest Haskell Programming from First Principles or Get Programming With Haskell. The first is better if you are interested in building up your Haskell knowledge from the bottom up. The second is better if you would like to start writing programs in Haskell as soon as possible.
Haskell Programming from First Principles
If youâre searching for the book that will contain everything you need to start writing Haskell, Haskell Programming from First Principles by Christoph Allen and Julie Moronuki is the choice.
Itâs very exhaustive and will build your Haskell knowledge from the ground up, starting with lambda calculus and basic Haskell syntax, then covering all the common typeclasses, monads such as State and Reader, monad transformers, and IO. The explanations are very beginner-friendly, and there are plenty of exercises to try out your new knowledge.
At the same time, itâs a little bit too verbose for my taste and sometimes feels more like a lexicon/reference than a beginner programming book.
Get Programming with Haskell
This is the book that Iâd personally suggest.
In contrast to HPFP, Get Programming with Haskell will help you make usable programs before delving into the theory of functors, monads, etc. It follows a more practical approach, covering only the essentials and then moving on to show you how to build things like small command-line applications, work with texts, IO, glitch JPEGs, and other fun stuff.
Learn You a Haskell for Great Good!
As a commonly recommended resource, Learn You a Haskell deserves mention here as well.
It might be a good third choice if the books above donât suit you and you are dead set on reading a book, but I would generally recommend avoiding it.
Unfortunately, one can feel that time has passed since the release. Some of the code examples supposedly donât work anymore, and the official website is sometimes down. In addition, it doesnât contain any exercises.
There have been some community-organized efforts to create better forks of it, but nothing substantial.
đšâđ« Haskell courses
If reading books isnât exactly your thing, here are some Haskell courses that should get you writing Haskell as fast as possible. There are two options to choose from here: something like Type Classes or learn4haskell can be very useful for getting started with the Haskell syntax and basic language constructs, while the more university-focused courses from Erik Meijer or Graham Hutton will help you start thinking like a functional programmer.
Type Classes
Type Classes is a collection of courses created by Julie Moronuki and Chris Martin. Julie previously worked on Haskell Programming from First Principles, a book I mentioned as a good choice for beginners.
I believe these courses are even better than the book. As far as I saw, the material is well structured and accommodates different styles of learning by having lessons in both video and text. New courses are regularly added to the website. Thereâs just one downside: the rather costly subscription fee.
But donât worry. The most important Type Classes course for beginners is the beginner crash course, which you can view for free.
Haskell Beginners 2022 and learn4haskell
Dmitrii Kovanikov has published video recordings from his free Haskell course for beginners, which you can find on his YouTube channel. The course is short and sweet, covering FP, syntax, data types, functors, and monads in just 4 hours.
It covers more or less the same ground as learn4haskell â a GitHub-based course that helps you learn Haskell by making 4 pull requests â which Dmitrii did together with Veronika Romashkina.
If your goal is to get to writing monads as quickly as possible, one of these could be the best possible choice. Both the YouTube course and the GitHub course are very accessible and quite fun.
Introduction to Functional Programming
If you would like to take a fundamentals-focused approach towards learning Haskell, Introduction to Functional Programming could be the choice for you. It is an online course taught by Erik Meijer that uses Haskell to teach you how to think about programs and write them in any functional programming language.
Functional Programming in Haskell
Graham Hutton has uploaded two sets of lectures from Nottingham University on his YouTube channel: Functional Programming in Haskell and Advanced Functional Programming in Haskell.
The first course covers functional programming, basic Haskell syntax, and how to work with types, type classes, and functions. The second course shows how to create a sudoku solver in Haskell and covers functors and monads.
The lectures are clear and well-polished, and you canât go wrong with spending your time watching them.
đœïž Haskell videos
If youâre searching for something more to watch on YouTube, I have your back.
Haskell for Imperative Programmers
Haskell for Imperative Programmers is a fantastic series of short videos that teaches functional programming in Haskell.
In comparison to the courses listed above, the sequencing of topics feels a bit arbitrary, so I wouldnât try to learn Haskell just by watching these series. But the individual videos are very well made. If you need to understand a specific topic, they are a good option.
Category Theory for Programmers
Category Theory for Programmers by Bartosz Milewski is a series of videos that covers basics of category theory â the place from which all the scary Haskell words such as functors, monads, etc. come from â in a programmer-friendly fashion.
Itâs an excellent playlist to watch if youâre interested in these kinds of things, and it will help you better understand how Haskell works. At the same time, remember that you donât need to know category theory to write perfectly fine Haskell programs.
đ„ Other resources
Exercism
Exercism is a great option to get used to writing code in Haskell or any other programming language they offer. The Haskell track has plenty of exercises to keep you occupied for a while, and you can get free help with your code from the awesome mentors that contribute their time there.
CodinGame
CodinGame might appeal to competitively-minded programmers. It is similar in purpose to Exercism, but in contrast to Exercism, it is structured more like a game. You can compete with other players in timed code clashes, program bots, and, of course, do LeetCode-like problems as well.
What I Wish I Knew When Learning Haskell
What I Wish I Knew When Learning Haskell is an extensive Haskell resource created by Stephen Diehl. It isnât really something I would read from start to finish, but if you need to reference something, I would see if it isnât covered there first.
Monday Morning Haskell
Monday Morning Haskell is a website with a ton of resources, starting from beginner Haskell mini-courses to advanced real-world Haskell tutorials.
Haskell for all
While not entirely a beginner resource, Haskell for all is an accessible blog by Gabriella Gonzalez that has been active for a decade already, and I highly recommend checking it out while learning Haskell.
For example, reading an article such as Electoral vote distributions are Monoids while learning about monoids in Haskell can help you better understand the typeclass and how it can be used in real-life code.
Serokell Blog
Our blog contains a lot of Haskell articles that you can check out by visiting our Haskell tag. If you want to keep informed about new articles, I suggest signing up to our newsletter (sign-up form below) or following us on Twitter.
Visit our Haskell consulting page to learn about the custom business solutions we design using this programming language.
I hope this list helps you in your journey of learning Haskell. If you have any other resources that youâve enjoyed and would like to add to this post, you can contact me on Twitter or send me an email.