Hi everyone,

this is the first book I write about, but it’s so well written and amusing that I’ve decided to blog my personal review.

#### As it started

Well, let’s start from the basics: Learn You a Haskell is an amazing book you can read online for free, or even buy the printed edition (as I did). In my opinion it’s definitely the best book on Haskell around. I stumbled upon this book accidentally: I was just bored, looking for some new cool programming language to learn. I’ve already met Haskell six months ago, but it rapidly lost in interest because I judged it too weird and complicated, studying it on the famous “*Real World Haskell*“. Meanwhile, I’ve played a lot with Clojure and Lispy stuff. One day, I decided that I want to learn a language not only cool, expressive and functional as Clojure, but that I wanted a language to be **fast** and that can be compile **cross platform **(and **functional**, of course!) so I’ve thought about Haskell. Looking around into the books panorama, I found the site and the book: when I saw that it was edited by the amazing No Starch Press, featuring also the awesome Land of Lisp, I had no more doubt, I just bought it!

#### From rookie to master in 15 colorful chapters

This book is a little miracle indeed: you start thinking “Oh my God I’m an Haskell newbie, I won’t grasp Monads and other scaring stuff” and you finished thinking “So this are Monads about? They are so simple, it can be!”. The author guides you through all 15 chapters with a step-to-step approach: your path from functors to monads is built brick after brick. The amusing thing is that I’m reading it (indeed I haven’t finished it yet, 30 pages left 😛 ) at night just before going to sleep, and it’s so clear and simple that I can even understand everything!

Technically speaking, this book simply saved Haskell for me: before it, I considered Haskell a not-so-cool functional language, but this book changed everything.

#### The book, squeezed up

I’ve decided to go a step further into this book review, summarizing and giving an opinion of every book’s chapter:

- Starting Out: Your first Haskell file, plus a lot of cool stuff, e.g. ranges and list comprehensions. You will end thinking “Why I need range(1,20) or “for i = 0; i < 20; i++” when I have 1 .. 20? List comprehensions are awesome, too.
- Types and Typeclasses: Some Haskell’s basic types acquaintance. You will go deeper into the topic starting to Chp. 7
- Syntax in Functions: some basic syntax you can live without. You can already write some non-trivial functions, in my opinion; they will be a little verbose, but correct.
- Recursion: If you are familiar with functional language, go swiftly and fast through this.
- Higher Order Functions: the Haskell awesomeness begin to emerge. Haskell is a language where you have some kind of cool stuff just out-the-box: currying, lazyness and more. Sure, they come with a price, but come on, just enjoy them meanwhile!
- Modules: you will struggle with modules, and this chapter helps you to get thing a little less painful.
- Making Our Own Types and Typeclasses: by far, one of most important chapter: if you wanna do serious Haskell development make sure to squeeze out this chapter and the beautiful Haskell Type System. As a bonus, your first encounter with Functors!
- Input and Output: a light and pleasant chapter about Haskell IO. My advice is to skip this chapter and the next one for now. Come back with your overpowered Monad knowledge, and things will be much clearer (despite the fact they are clear even without any preliminar Monad knowledge).
- More input and output: I don’t know why, this chapter is not present into the online version: the author preferred to merge its content into the Chp. 8 (see above).
- Functionally Solving Problems: You can skip this, a collection of problems solved with functional thinking. Useful to take a pause and do some practice.
- Functors, Applicative Functors and Monoids: Here the author have merged all the cool stuff into this chapter, but into the printed version Chp. 11 is just “Applicative Functors”, and it’s only dedicated to that topic. Strange. In this extra-condensed chapter you will encounter functors, applicative functors (beefed-up functors) and monoid (for wrapping existing types). With them you will be finally able to respond to this question “What the hell Maybe is useful about?”
- A Fistful of Monads: Correspond to the book’s 13th Chapter. You will finally meet the legendary creature of Haskell programming: the powerful and terrifying Monad (I don’t why I thing to a Monad as a tibetan Monk).
- For a Few Monads More: After having grasped what monads are about, you’ll met useful and fantastic Monad, such as Writer, Reader and the atomic-one: the State Monad!
- Zippers: Perfect conclusion for the book; learn to use powerful Haskell functions based on Monoids and Monads

#### Conclusion

*Learn You a Haskell* is an amazing book, written by a very passionate author, for a fantastic programming language, Haskell. Give them both a try, you won’t regret! After all, Ada language is used into mission critial software, and Haskell has been influenced by Ada: This can’t be for accident, after all, don’t you believe?

See you!

Alfredo

“for pure case” ?

Whoops 😀 Fixed 😛

A small detail: monoids aren’t “beefed-up applicatives”. They’re completely orthogonal to the functor/applicative/monad ladder, and I’d say they embody a much simpler idea.

They’re also completely different things from a technical standpoint: “applicative functor” (like “functor” and “monad”) is a term that applies to parameterized type constructors with one parameter, like IO, Maybe or []. “Monoid”, on the other hand, applies to concrete types like Int and Bool (said more compactly, members of the Applicative class have kind (* -> *) whereas members of Monoid have kind (*)).

Yea, you’re right 🙂 Monoids are a costruct for wrapping existing types into something else, that can be used in some way 😛 (for example with mappend, mconcat and mempty)

What do you mean with ‘Monoids are a construct for wrapping existing types into something else’? To say something is a monoid (by looking at the minimal definition of the Monoid class) is to express mempty and mappend for some type T. So, basically, it is expressing a no-op

and a binary combination of expressions (of type T) for a type T that is a Monoid where you uphold the rules of closure, associativity and “identity element” (http://en.wikipedia.org/wiki/Monoid).

Example.

instance Monoid Integer where

mzero=0

mappend=(+)

Perhaps I am missing something. If you want to inject (“wrap”) types into ‘something else’ you have Monads.