August 17, 2007

Haskell

Video of a talk given by Simon Peyton-Jones (one of the Haskell language designers) at OSCON 2007 has been making the rounds, and I finally got around to viewing it.
  • Part 1 (Flash video, the basics)
  • Part 2 (Flash video, the interesting stuff)
  • Slides (7.1MB PDF)
I had a "Holy shit!" moment on slide 54, regarding Haskell's type system. (Sorry, you'll just have to see for yourself. I haven't internalized it well enough to explain it in English yet.) Plus, I finally understand what monads are, and why they're so important.

Basically, Haskell's version of monads are a way of labelling all the bits of your program where order of execution is important. Since Haskell enforces this labelling, through its type system, Haskell compilers can optimize the hell out of the purely functional parts of the program (taking advantage of lazy evaluation, referential transparency, and all kinds of other fun(ctional) stuff), while guaranteeing that the bits of your program that have to execute in a particular order will, in fact, do so. The language is set up in a way that subtly encourages you to keep the imperative parts of your programs to a minimum.

I didn't understand this clearly before because Haskell monads are so intertwingled with Haskell's type system that you must first have a good understanding of the type system before you can understand any monad examples.

0 Comments:

Post a Comment

<< Home