enjoying salad since 1978.

Sunday, April 01, 2007

Haskell thoughts.

Writing A Lisp Interpreter In Haskell is a fun article about writing a Lisp interpreter in less than 200 lines of Haskell, repl and all. His experiences with Haskell's expressiveness and concision mirror my own. I am just blown away by how difficult programs are easy to express in the language while still being easy to change as your approach to the problem's solution changes.

It takes quite a lot to effort to learn Haskell. One of those "learn haskell in an hour with our fancy tutorial" so prevalent in other languages will not adequately prepare you for any semi-serious Haskell code; there is simply too much to the language for a quick flyover. I've read several books and papers and written maybe 5k lines of Haskell now and I still feel like I've just scratched the surface. My experience in Lisp, Erlang, and ML have helped me quite a bit but the only way to achieve any success in this language is to start digging, I think.

A few of my favorite haskell features sofar:

  • partial application and currying are built into the language and are very natural to use.
  • use of higher order functions also require no painful machinations.
  • anonymous functions can be created anywhere with only three extra characters.
  • algebraic data types.

I'm a little down on Monads although the article linked to above has given me a new perspective on them. I've been learning category theory to help me find more novel uses than just abstracting away IO but no deep insight has hit me yet. I'm prepared to give it time, I believe it will pay off.

3 Comments:

Blogger Evan said...

There are lots of different ways of approaching monads and I think a different way works for everyone, but for me it was SPJ's paper "tackling the awkward squad" and then all about monads. The latter is a practical and succinct overview of many different applications of monads, and seeing them all together like that for me was very helpful in generalizing from IO to "computation".

8:28 AM

 
Blogger Steve Jenson said...

I'd seen all about monads but not the SPJ paper. Think I'll take a printout to the coffee shop tomorrow.

BTW, I found your Haskell for Programmers useful when I was first deciding to learn the language. Your comment that I would need to think at a higher level of abstraction put me in the right mind-set. So thanks!

6:17 PM

 
Blogger Ezra Cooper said...

My favorite article about monads is actually not about monads: Conor McBride's "Applicative Functors with Effects." There he describes "idioms" (now known as "applicative functors") which are a generalization of monads, and (in some ways, maybe) a more natural variant of monads.

2:50 PM

 

Post a Comment

Links to this post:

Create a Link

<< Home