Sunday, November 26, 2006

Some Thoughts on Haskell

I have been reading quite a bit about the programming language Haskell. It looks like Haskell is succeeding in the goal of consolidating the attention of a lot of programming language researchers into a single language, or at least a single core language with a variety of extensions.

Haskell is extremely expressive and dense, but so are lots of other languages. What interests me most about it is that it makes you wear the "hair shirt," as Simon Peyton-Jones describes purely functional programming in this presentation. I have used Dylan and NewtonScript for real-world projects, but only dabbled in Scheme; one reason is that I tend to have trouble coming up with the functional way to do things. I've got too much imperative programming under my belt. I've learned to think in terms of lambdas and closures and recursive functions, but I have not really gotten into the purely functional mindset. So my thinking goes that if I learn Haskell, then programming using the idioms of map and fold and all that will start to make sense. In fact, I might not bother going back to Scheme.

Haskell is an even "redder" pill than Lisp or Scheme in that regard. And it supports type inference, which has interesting implications for compilation and run-time efficiency. It also supports a programming idiom I am still trying to wrap my head around: monads.

I've worked through some very elementary category theory in the book Conceptual Mathematics: a First Introduction to Categories by Lawvere and Schanuel. You can find more about Monads in programming in this paper. John Shutt has a tech report here which looks promising in that the text outweighs the pure math notation; I've set as my goal a complete understanding of Schutt's paper. And Schutt's paper doesn't go very deep; it's an introduction. But even that will be hard enough for me for now. The rabbit hole goes much deeper!