Saturday, January 6, 2007

A Nice Way to Learn FP

Over the past Christmas break I had some free time available and wanted to use it wisely. I decided that I've been flirting long enough with learning functional programming, like learning OCaml and Common Lisp and all that. This time I was going to just jump right in to Haskell. But, why learn just one FP language? I quickly found a tutorial at:

that covers an implementation of Scheme in Haskell, so you learn both although there's a few features of Scheme that aren't implemented.

One of the nice things is that you have a fully working Scheme interpreter so you can play around with it as much as you like. Plus at the end they even mention catamorphisms and anamorphisms and how to write a whole standard library with mostly folds and unfolds.

I supplemented that along with the book Haskell The Craft of Functional Programming, which is nice for beginners but wasn't as advanced as I hoped it would be. Ultimately I'm not sure I could recommend it to someone who already knows a programming language fairly well. I also checked out the wikibooks Haskell page at which was a well-written tutorial.

Sadly I didn't learn enough over the break to be able to write a real program, but I did learn enough where I could think of some solutions to problems in Haskell. The downside is that when I went back to work coding in C++, I'd see a one line solution in Haskell and would have no way to translate that to C++.

No comments: