Saturday, January 26th, 2008...10:24 am
She Blinded Me with Haskell
I’m really fortunate to be taking some amazing courses from some awesome professors in my last semester as an undergrad at Penn; I’m taking a course on technology and policy from Matt Blaze, and another course on functional programming from Benjamin Pierce. After only a couple lectures from Matt Blaze on technology and privacy, I’ve become so terrified of identity theft that I canceled my PayPal account, removing my bank and credit card information from the web; I went through my Gmail, deleting all emails containing sensitive information; and I even stopped by the local RadioShack looking for a paper shredder. What a rush!
On a lighter note, my functional programming course has been a breath of fresh air after spending four months coding GNOME Do in C#; writing C# feels like writing a novel, while writing Haskell feels like writing a haiku. As part of our second assignment, we wrote functions to find the fringe, size, and height of a tree using higher-order functions:

This could be written more clearly, but just marvel at how concise the tree functions become when they are expressed in terms of a more abstract tree function, “treeOp”. treeOp takes one polymorphic function to apply to leaves and another polymorphic function to apply to branch values returned from recursive calls to treeOp. myFringe is expressed as a tree operation that applies :[] (the singleton list constructor) to leaf values and ++ (list concatenation function) to branches. The result of calling myFringe is an in-order list of leaf values. Amazing!
2 Comments
February 1st, 2008 at 6:55 am
The juxtaposition of these two subjects amazed me. I printed the post and shredded it immediately!
February 8th, 2008 at 9:26 am
Hey Dave, yeah believe it or not I’m actually taking a functional programming course here as well at Dartmouth and we also use Haskell. I’m a big C/Python person myself but when I could write functions in 3 lines that would’ve taken me dozens in C, I fell in love. It really is a beautiful language. Plus, it teaches you a lot of how to think!
Leave a Reply