Immersive Journey Through the Strange and Beautiful Land of Haskell, 2009-03-16
Reviewer rating:
Learning Haskell is an intriguing exercise. Foundational concepts--syntax, monads, byzantine compiler error messages and various bits of jargon--are as puzzling and subtle as they are legion. Resources are scattered through various papers, books, and tutorials, and despite the wide efforts of volunteers in the Haskell community to consolidate introductory information, the Haskell community has always needed a practical, hands on, go-to tutorial-oriented book. In this, the authors delivered.
Although the book can be digested a la carte, as a set of unrelated, specialized tutorials, the authors also take care to use syntax, idioms, and library functions only once they have been clearly introduced, and to build upon these concepts, making it a pleasant read straight through---a difficult feat in a language rife with many foreign yet intertwined foundational concepts (at least, foreign to even the typical smart program of imperative background).
Many chapter titles in the book sound like they would focus on a narrow topic that may not be of interest to the general aspiring Haskell programmer, such as:
Chapter 5. Writing a Library: Working with JSON Data
Chapter 8. Efficient File Processing, Regular Expressions, and Filename Matching
Chapter 10. Code Case Study: Parsing a Binary Data Format
Chapter 12. Barcode Recognition
Chapter 22. Extended Example: Web Client Programming
Chapter 26. Advanced Library Design: Building a Bloom Filter
In fact, I found that these chapters flowed gracefully with the overall narrative of the book. Typically compelling, and full of carefully grown and expanded examples of appropriate length, they reinforced prior principles and practices, interjecting nuggets of generally useful advice, such as:
"If you find yourself proudly thinking that a particular piece of code is fiendishly clever, stop and consider whether you'll be able to understand it again after you've stepped away from it for a month."
(p.232)
The well explained examples grow organically like real code out in the wild---not just born, fully formed from some genius professor's head. Code is refactored, features are added, style improved.
The book seems to target multiple levels of Haskell programmer. I would consider myself somewhere in the intermediate Haskell programmer range but am constantly impressed at the useful pointers and subtle approaches I seemed to have missed along my own Haskell learning journey, for example library functions I should have known about years ago but never managed to run into in the wild. The authors' consistent use of ghci for prototyping, debugging, and API lookup reminds Haskell programmers of all stripes to use the powerful tools provided by GHC.
Deeper concepts are often injected throughout the stream of tutorial and not skipped over entirely; they are either reserved for later in the book, or are at least given an appropriate footnote or reference, such as this deep gem in the beginning of the book (Chapter 2: Types and Functions):
"There is a deep mathematical sense in which any non-pathological [pure] function of type (a,b) -> a must do exactly what fst does. Moreover, this line of reasoning extends to more complicated polymorphic functions. The paper [Theorems for Free, Wadler89] covers this procedure in depth."
I would expect the depth of this to be missed by all but the most mathematically minded of novice Haskell programmers, but it's great to see that even in a tutorial oriented, practical book, the authors still manage to plumb some of the depths of Haskell's beautiful theoretical core.
Other sticky concepts, for example, Overlapping Instances and other pragmatic type-fu, are explained from a practical point of view without dwelling unnecessarily on their weirdness or asymmetry: the goal is clearly to get work done.
Despite the fact that the text is available online, it's great to have a copy of this book in hand, to bookmark and highlight its 600+ pages. I just finished it once through and I'm already relishing reading and referencing it again and again.