[2015-01-05] “Learn You A Haskell For Great Good”

Learn You A Haskell For Great Good” is a nice book with a weird title written by Miran Lipovača. It gently introduces you to functional programming with the Haskell programming language and manages to cover a surprising amount of ground without being intimidating. The author and his publisher have very kindly made the entire book available for free on-line. I think it is a great resource to start learning Haskell, but by itself it is unfortunately not enough to become proficient.

The first thing that strikes you about the book is how informal the writing style is, not to mention the occasional humorous notes. The author also provides several nice hand-drawn images to enliven the text. When you consider that this book has been written by a non-native speaker of English from Slovenia who was a young Computer Science student at the time he wrote the book and who is also good at drawing, you realize the magnitude of his achievement. Kudos to him for having written a great first book that is clearly a labor of love.

The book covers almost everything you generally hear about Haskell, without getting ensnared in Monads and Category Theory as seems to be the fate of almost every tutorial on Haskell, which scares newcomers away. However, it does assume that you're already familiar with (at least) imperative programming, so it is not good as a first book on computer programming. It gradually covers list-comprehensions, currying, type-classes, recursion, functors, modules, monads, monoids, etc. without making a big fuss about them and (mostly) showing the motivation behind them.

There are a few things amiss though. The book doesn't have any exercises, so it doesn't force you to check what you have learned and work out how you might apply it to solve problems. The second half of the book seems to be a bit dense without a clear explanation for the motivation. For example, I read through the section on applicative functors, but couldn't figure out why I should care about them until later in the book and even then I wasn't so sure. Surprisingly, the book doesn't show you how to write comments in your code (use -- for single-line comments; {- and -} for block comments). Finally, I feel the author should have spent some time providing tips on the biggest stumbling block with Haskell for beginners: the rather dense type-related error messages spit by GHC for the smallest of mistakes.

While you can start playing with Haskell for simple problems using the knowledge you gained from this book, it most likely would not be enough to write and debug non-trivial programs. For that, you will probably need a book like Real World Haskell. You should check out the recommendations by Ramanathan Muthukrishnan for learning Haskell and functional programming.

Other Posts from 2015