Hodza Nassredin home

Book review Beginning Haskell A Project-Based Approach.

05 January 2016 – Karelia

Several years ago I tried to read different books about Haskell and had never finished. For example when I started “Real World Haskell” everything was ok until chapter about monads. It was just to hard for me to understand monads when I even had troubles with understanding of (.) and ($) operators. But now when I spent more than two years with Fsharp I decided to give it another try. But RWH now seems to be a little bit outdated and I checked several books in stores and finally bought Beginning Haskell A Project-Based Approach by Alejandro Serrano Mena. Yesterday I finally finished it and I’m proud of that.))

Book summary

Every book has three types of content: boring, interesting, hard. Mainly theses types are subjective because every reader has different skills and knowledge and the book, at the same time, focuses on a wide audience. And it is always hard to keep a balance between simplicity and complexity. So I prefer books where every chapter is orthogonal to each other so I can skip parts which I understand and concentrate on interesting and hard parts. But book usually is not just a collection of articles, but has some context and main theme to connect different concepts and describes how to use them together. And now I can conclude that this book probably not perfect, but very good in terms of that. Before reading I had knowledge about monads, monoids, type classes, monad transformers, but I never had a whole picture. And this book finally connects everything in my head. The book is modern so it descries latest changes in GHC and mention Stack. It is also practical, main theme is how to build online store in Haskell. But do not expect something like Agile Web Development with Rails 4. It is always funny when people from Haskell, Golang, Fsharp(Suave.IO ;-)) … are trying to sell their minimal web frameworks as a “You can do everything”. All of them are too far away from Django and Rails. I recommend not to fight with giants, but to sell them for more appropriate tasks. For example Golang’s http is for speed, Suave.IO is for minimalistic web services/front ends with very complex logic or for extremely complex SPAs when used with WebSharper or when you need to keep common code base for frontend Xamarin app and backend api server. So the book is very practical, it even describes K-means for clients clustering. The book describes a lot, but unfortunately some things are mentioned, but not described(free monads) or not mentioned at all(comonads). So if you are like me or just a fp beginner I highly recommend this book.

Chapters summary

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

This chapter is where hard stuff starts. It was also interesting to find that Update computation expression also exists as RWS monad in Haskell.

Chapter 7

Chapter 8

Cloud Haskell is a super combo of mbrace with erlang.

Chapter 9

Chapter 10

I thought that python 2 strings is a mess. No. Haskell is a clear winner: 5 types for string representation !!!

Chapter 11

It is always funny for dot net dev(linq, type providers) to read about how cool is XXX strongly typed lib for db access. This part is a good example of how Haskell sucks when comparing with more modern c# and f#. All that dirty template workarounds.

Chapter 12

Chapter 13

I know GADT and phantom types, but description in that part really sucks. Really hard to understand what is going on.

Chapter 14

Chapter 15

Chapter 16

Appendix 1

Links, summary.

Appendix 2

Spoiler do not click if you are going to read the book ;-)]

P.S.

I still doesn’t know Haskell well and have just a small understanding of monads, but now I can read Haskell code. Will I use Haskell? Definitely no. I’ve already have golang for speed, python for ready to use libs, ml and web programming, fsharp for business logic and web/mobile UI. So I don’t see a place for Haskell in my life. But now I have ability to bring some patterns from Haskell to my Fhsarp code and also know some interesting stuff to learn like attribute grammars. What’s next? I’ve almost finished to learn existing mainstream languages. This year I’m going to refresh my knowledge of clojure/racket and will try to use them intensively. Because SICP is still the best. I will write a blog post about that next January. Will be interesting to finally compare clojure and fsharp. Who is number one?

Further reading

comments powered by Disqus
Fork me on GitHub