The Haskell School Of Expression by Paul Hudak

The Haskell School of Expression is an introduction to the Haskell programming language.
This was by far the best programming language tutorial that I have ever read.
 
Using an application for drawing and calculating data about shapes, the book shows us the power of functional programming building through a number of chapters into an application that handles reactive animation. On the way we learn about the power of the abstractions that functional programming languages offer, as well as features such as Monads, streams and type classes. The reactive animation example shows beautifully how a domain specific language can be embedded into Haskell.
 
For example, you can run a simple paddleball game by loading Reactivate.lhs into Hugs and typing:
 
>  test (paddleball 1.0)
 
The ball has the following definition high level definition which is relativly easy to read:
 
> pball vel =
>  let xvel    = vel `stepAccum` xbounce ->> negate
>      xpos    = integral xvel
>      xbounce = when (xpos >*  2 ||* xpos <* -2)
>      yvel    = vel `stepAccum` ybounce ->> negate
>      ypos    = integral yvel
>      ybounce = when (ypos >* 1.5
>                ||* ypos      `between` (-2.0,-1.5) &&*
>                    fst mouse `between` (xpos-0.25,xpos+0.25))
>  in paint yellow (translate (xpos, ypos) (ell 0.2 0.2))
Additional examples of generating Midi files and simulating a robot on the screen demonstrate how easy it is to build on top of the previously implemented modules. Many questions at the end of most chapters help illuminate the text. Fantastic!
 
The programming environment used, HUGS, can be downloaded from this page which also has an installer for installing all of the examples from the book.
Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s