Learning Haskell and FP

Fritz K Ruehr fruehr@willamette.edu
Thu, 28 Dec 2000 16:42:32 -0800 (PST)

[ Doug Ransom wrote about wanting a more advanced and design-oriented book
  on FP than "The Craft of Functional Programming" by Simon Thompson.
  In reply, Johan Jeuring recommended the Advanced Schools books (I concur). 

Let me add a few other recommendations, plus a vision of a book (not
yet written, as far as I know) which might fit Doug's needs; I'll
call it "The Design Patterns Haskell Companion" (see below).

The "actual book" recommendations (all documented on haskell.org):

 * Introduction to Functional Programming using Haskell (second edition)
   by Richard Bird (Prentice Hall, ISBN: 0-13-484346-0)
   This book is an introductory text, like CFP, but it ramps up a bit
   faster and addresses design issues from a more advanced perspective
   (IMHO). It's certainly an excellent text, and it builds to a nice
   medium-sized design example (the program calculator of Chapter 12).
   It also leans toward a different style of design and programming,
   influenced by BMF/Squiggol.

 * Algebra of Programming
   by Richard Bird and Oege de Moor (Prentice Hall, ISBN: 0-13-507245-X)
   You might think of this as an advanced sequel to IFPH above, 
   although it focuses more on the theory behind program calculation:
   categories and allegories figure prominently, and it leans even 
   further in the direction indicated above. But there is nevertheless 
   a lot of good material here which can serve as a foundation for 
   design work, esp. the final chapters (7-10) on algorithms topics.

 * Algorithms: A Functional Programming Approach
   by Fethi Rabhi and Guy Lapalme (Addison-Wesley, ISBN: 0-201-59604-0)
   This is a concise tour through the usual gamut of data structures 
   and algorithms topics typical of a "CS 2" course, but from a 
   functional perspective. It is addressed more to people who are 
   already familiar with programming and with the "standard" approach
   to DSA issues. It works very well as a reference but includes 
   enough discussion to reward a straight reading.

 * Purely Functional Data Structures
   by Chris Okasaki (Cambridge University Press, ISBN: 0-521-66350-4)
   This one is similar to AFPA above (in being a tour of DSA topics from
   a functional perspective), but is a bit more advanced: e.g., Ch. 3
   covers leftist heaps, binomial heaps and red-black trees. It also
   addresses issues of analysis in the context of lazy evaluation more
   thoroughly (Banker's method, etc.). The examples are written using
   SML, but an appendix (and a website) give Haskell versions.

Of course, none of these books really answers the needs of the mature
programmer/blossoming functional programmer who seeks advice on
broader design issues in the context of lazy FP, esp. Haskell.
This gap leads me to propose the fanciful book mentioned above:

 * The Design Patterns Haskell Companion
   by [someone(s) reading this list?]

The title may be pandering a bit, but if the Smalltalk people can do it,
why can't we? :) . In fact, the title is based on "The Design Patterns
Smalltalk Companion" by Alpert, Brown and Woolf, a book I came across
while reading up on design patterns. (It was recommended by a customer
review on Amazon as being better than the original "gang of four" book.)

The "Smalltalk Companion" serves an audience of mature programmers and
attempts to document a number of "standard" design patterns in the
specific context of Smalltalk. I'm not sure that the Haskell community
would be comfortable referring to its collective design folklore in
these terms, but I'm sure we would all welcome a good book written at
this level which systematically addressed the motivation, rationale,
trade-offs, etc. of the more advanced techniques of FP (i.e., monads, 
type and constructor classes, Xa-morphisms (for various X), 
higher-order and nested datatypes, etc.).

As Johan mentioned, the "Advanced School" books serve this purpose to an
extent, but they differ from my vision in two respects: first, they are
collections of chapters on particular topics, written by different
authors, and thus don't form a consistent, systematic review. Second,
they are not (all) written from the specific perspective of design, so
that for example they don't provide as much comparison and contrast
*between* techniques.

Of course, another motivation for such a book is that it might lend an
air of credibility and maturity to the language, thus helping to 
promote it in the larger world. Casting it in terms of "design patterns"
would certainly make sense for these purposes (and probably guarantees
a certain audience, too), although I am still ambivalent about the need
for Haskell to become a huge hit with mainstream audiences.

In any case, if anyone is interested to write such a book, I will buy
a copy :) . And if anyone wishes to collabrate on it, I am willing
to help out. (I am not qualified to write it alone, and I think it 
would turn out best as a group effort in any case.)

  --  Fritz Ruehr