Learn You A Haskell For Great Good

by sandersn 28. May 2011 08:30

 

If you visit learnyouahaskell.com, you'll see that Learn You a Haskell For Great Good originated as a Haskell tutorial when the author decided he wanted to make sure he really knew Haskell. Haskell tutorials are a dime a dozen, especially monad tutorials, but that's exactly what it is; an introductory Haskell tutorial followed by a monad tutorial. It has the distinction that it is very well explained and much more complete than the average tutorial, as well as now existing in dead tree form. But it is not like Real World Haskell, which explains concepts in the order a practising coder would need to get a useful program off the ground. Learn You A Haskell For Great Good assumes that you are a practising coder in an imperative language, but generally explains concepts in order from simplest to most complex.

 

That's cool if you want a summary of the language, and if you're approaching Haskell as an enthusiast rather than a practitioner then you will probably like it. The focus is on expanding your mind, not (for example) finding the right tradeoffs between safe and succinct. It's arguable that this is the right approach for Haskell, which was traditionally a research playground, and the that the people behind Real World Haskell are engaging in wishful thinking when they try to make Haskell a production language.

 

Personally I prefer the practical approach (I've even used Haskell for scripting (!) before), but the tutorial approach has its advantages; it's a lot more thorough, and it covers cool new stuff in favour of things like database libraries. Even after 2-3 years of Haskell use, I learned interesting new things about Haskell's kinds, applicative functors and zippers.

 

The book is divided into two tuturials: basic Haskell and monads. The basic Haskell section is not too surprising--it covers the syntax and semantics of the basic constructs of the language. I think it could have done with a bit more emphasis on solving problems recursively, because the primary difficulty of learning Haskell is not the syntax. Really, it assumes that you are an intelligent person who is willing to work through new concepts yourself. If you don't already know at least one of: Lisp*, Erlang or ML*, then for additional help, you might want look at the Little Schemer, which does a great job of teaching recursive thinking without much language overhead.

 

*Popular members of the Lisp family are Scheme, Common Lisp and Clojure. Popular members of the ML family are F#, Caml and SML.

 

The other half of the book is a monad tutorial. It's tied with Real World Haskell for the best tutorial I've read. Instead of starting with ugly code and cleaning it up, Learn You a Haskell starts with functors, then progresses through applicative functors, monoids and on to monads. Although I suspect that this order does not recapitulate the history of these libraries, it makes a lot of sense. You get to see how functors generalise `map` on lists, then how applicative functors allow arbitrary functions to be lifted and applied in a functor (as well as providing left-to-right evaluation, which is something I missed when I was learning monads), finally ending with the way that monads allow chaining of functions to produce an imperative style.

 

I don't know if this is how the web site presented it--it takes a lot of space, but I think that it's worth it. If you have bounced off monad tutorials in the past, this one may work for you. You'll do a lot of reading, but you'll also end up with a wide, solid base for understanding monad usage.

 

Besides, if you get bored, there's always the fact that Learn You a Haskell is Officially Funny. However, the humour quickly fades into the background. This is no _why's Poignant Guide--the humour is closer to the occasional cracks in my ancient Learn Visual J++ 1.1 book. Well, I guess the drawing are pretty cool. I can't believe Capcom let them include a cartoony sketch of Quickman, but it's AWESOME. (There's also a Wiggler from Mario used to demonstrate head/tail.) Unfortunately, the drawings too fade into the background as they become less topical, or at least start referring to pop culture that I haven't heard of. Overall, it reminds me a lot of O'Reilly-quality writing. That's good but (and here I'm biased) not too surprising coming from the extraordinarily literate Haskell community.

 

Although the writing is good, it's hard for me to estimate how good the book is at teaching, since I already know Haskell. Fortunately, there is a chapter on zippers tucked in at the end, so I can use that to estimate for the rest of the book. Here, I easily acquired an intuitive understanding of what zippers are and how they work--the examples and analogies were good. But I didn't feel like I got a concrete understanding of their implementations, or when I'd need to implement my own. I'll need to actually play with zippers myself to understand them properly.

 

Bottom line: I didn't think too much of the basic Haskell tutorial, but I liked the monad tutorial. It's worthwhile if you have the patience to read the whole thing. Compared to the other two Haskell books I own, Haskell: The Craft of Functional Programming  (Thompson) and Real World Haskell (O'Sullivan, Goerzen & Stewart), Learn You a Haskell For Great Good fills the niche for smart programmers who already know an imperative language and want to learn Haskell for its own sake, covering concepts thoroughly whether or not they will be practically useful. The result is a more focussed book that covers less.

Tags: , , , ,

Books | Language | Programming

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading