# Books/Tutorials

## How would you like to contribute to the Craft of FP exercises/solutions project?

*19*

## Learning Haskell with Craft of FP book (self-study)

Hi!

Sometime ago I asked on haskell-caffe list about the solutions to the exercises from the Simon Thompson's book Craft of FP (see thread) and there were different opinions whether they should be available or not for the public.

Being the one which practice self-study in order to learn Haskell and taking into consideration that Simon's book is one of the unofficial textbooks for the subject, I hope that having help in solving the exercises from the book can bring some benefit to the Haskell freshmans (according to the Your stage of Haskell Evolution? poll, we are majority :-)

The Haskell Sequence site is a wonderful opportunity to help Haskell community grow, and if there is no objection, I'd post from time to time questions pertaining to the book's exercises which puzzles my (and hopefully) someone's else mind.

I'm going to create a small poll to see what would be the best way to deal with it.

Pls. give me your feedback.

Sincerely,

Gour

- gour's blog
- Login to post comments

## Simon Thompson is an amazing teacher

After tripping and stumbling through "Gentle" and "YAHT", I am worlds grateful for "Craft of Functional Programming" He is not just teaching Haskell, he is teaching you how to think about problem solving.

The reason I am so excited is he gave the following exercise:

Give a function orderTriple which puts the elements of a triple of three integers into ascending order.

Ok, so far, just an ordinary question. And in most other cases that's all you would get. In YAHT, you would have copious exercises like what you just saw. In Gentle, he would show you the solution and keeping moving. It is the next sentence in this exercise that sets Thompson apart from the crowd:

You might like to use the maxThree, middle, and minThree functions defined earlier.

Kapow! After reading the first part of the exercise, my mind immediately began to scramble over how to maintain state and iterate through the elements, deleting them as I found their place.

But then Thompson *decomposed* the problem into 3 simpler problems for me!

## The Essence of Functional Programming by Wadler

This article by Wadler is really quite astounding:

http://citeseer.ist.psu.edu/wadler92essence.html

He shows how to create variations of an interpreter using monads and discusses the superiority of the monadic approach of the CPS approach.

## All About Monads, A comprehensive guide to the theory and practice of monadic programming in Haskell.

Jeff Newbern's All About Monads is the best monad tutorial I've seen yet!

This tutorial starts with the most basic definition of a monad, and why you might want one. It covers most of the monad instances in the standard libraries, and also includes monad transformers. It wraps up nicely with links to Parsec, category theory, and arrows. You can read it online, or download as a zip file or tarball.

If you've been looking for a good monads tutorial, try this one first!

## "Algorithms: A Functional Programming Approach" by Fethi Rabhi and Guy Lapalme

Algorithms: A Functional Programming Approach is one of my top ten favorite computer science books. First, it covers the basics of Haskell and complexity theory. Then for each algorithm it gives first an easy to read implementation, and then a more efficient but harder to read implementation. Each of the transformations from clear to fast versions are discussed, and optimizations are explained. This book was also my first introduction to methodical step-by-step algorithmic optimization systems, in this case the Burstall & Darlington system. I've since used the lessons I learned in this book in my commercial work in Python, SQL, Java, and of course Haskell.

The best audience for this book is those who are looking for a second Haskell book, or new to algorithms, or would like to learn how to optimize pure (non-monadic) Haskell code systematically. The sections on top-down design techniques and dynamic programming would be of interest to programmers who are still learning and wish to know more about structuring larger programs.

Even with all that content, this softcover book is only 256 pages (coincidentally binary?), allowing for easy reading in any spare moment.

- Login to post comments