Learning more Haskell

(Minor update: Removed a double-quote too much. Darn [AutoPairs](http://www.jwwalker.com/pages/autopairs.html). Maybe it can be configured.)

[Jamis Buck](http://jamis.jamisbuck.org/articles/2005/10/30/learning-haskell) brought me back on track with learning Haskell: I have had the [Yet Another Haskell Tutorial PDF](http://www.isi.edu/~hdaume/htut/) on my laptop for ages, but those things don’t read themselves.

A sidenote: using Haskell feels loads more natural to me compared with Common Lisp. I try reading [Practical Common Lisp](http://www.gigamonkeys.com/book/), as well. Grabbing the first item off a list (aka the “head” of the list):

Haskell: head( ["olle", "floyd", "muhammad"] )

Lisp: ( first ( list "olle" "floyd" "muhammad" ) )

That [s-expression syntax](http://en.wikipedia.org/wiki/S-expression) comes to bite me all the time! (I had to review that Lisp statement a couple of times in an interactive environment, to find and remove my C-style parentheses, and make it s-exp’y.) Haskell’s form has a more C-programmer-natural feel to it; YMMV.

[tags]haskell,programming[/tags]

Published by Olle Jonsson

Human. Wears glasses and often a smile.

Join the Conversation

5 Comments

  1. I used to write a lot of Lisp, before I got sick of the complex spec, lack of portable functionality, and the difficulty involved in actually deploying an app. After the initial shock, I decided that I liked the s-expressions better than Haskell’s rich syntax, mainly because it’s easier to work with in Emacs; for instance, the editor can always guess the indentation right with Lisp, where it has to guess with Haskell.

    I guess that Haskell’s function call syntax is a little more C-like. Of course, it’ll bite you if you try to do that with multiple-argument functions. For instance, map(f, x : xs) not only won’t do the right thing, but it won’t even be a syntax error, because Haskell uses the comma for forming tuples, and function arguments are delimited by just whitespace. So, you have to write map f (x : xs). You end up tying a lot of parentheses, but I guess the program would end up being pretty noisy with all those commas and parentheses otherwise.

  2. Didn’t think of that right away, but Lisp is infinitely easier to write a parser for. Correctness? Just count the ()’s.

    My weakness when it comes to Lisp’s parentheses is not their profusion, but that s-expressions perversely have their “function name” inside the parenthesis. I’ll have to get used to it.

    I found your weblog using Technorati. Nice avatar, by the by.

  3. There’s a small error, I believe, in your code. A quadruple quote! I’m not sure I agree with your opinions, but Smalltalk and Ruby programming has taken the C-style parentheses out of me so I just might not see it. There are a lot of other things I don’t like about LISP, though, but I’m not LISP-savvy enough to believe in my own opinions just yet. Haskell does rock, though. Although I’m not especially Haskell-savvy either. (But man, it does rock.)

    You would think a purely functional language would be less C than LISP, no? I mean in a way that would overshadow the syntactic stuff.

  4. I blame AutoPairs. TextMate needs to ignore its extra pairs, when pairing parentheses.

    I’ll fix that, thank you.

  5. OK, to fix it in System Preferences, pick the AutoPairs PrefPane, and “Add Application…” Browse for Textmate, and select it. This adds a new item to the menu Configuration Set. Now, with this item already selected, uncheck all the boxes. Ta-da!

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.