Learning Haskell
Healthy living requires staying fit. And staying fit requires regular exercising. So I’ve decided it was time to learn a new programming language and have chosen Haskell. Why Haskell? The bottom line is that I think it has a few challenges for me along the way and I’m therefore most likely to learn a lot. The long answer goes like:
- It’s an academic language (meaning that it’s been designed mostly by academics, not that it’s restricted to academic usage). I’ve been mostly exposed to industry-driven languages so far, seeing the differences in design (if there are) is probably going to be interesting.
- It’s a purely functional language. Whereas I’m familiar with the functional theory (heck, I work on a Pi-Calculus engine) and have done some functional coding in Ruby or Javascript, I’ve never used a purely functional language since university.
- I’m a clear proponent of dynamic languages and typing. Which doesn’t mean that I think static typing is always bad, just that, for me, dynamic typing is usually better. Haskell is based on a type system that sounds to me very much like static typing done right: type classes with powerful inference.
- Haskell is lazy. Which means that it only executes what it feels like executing. Fortunately, it seems to be pretty smart at knowing what is necessary to be executed and what isn’t. This has interesting side effects (pun intended) like being able to support infinite lists. Not sure yet how useful that is but I intend to find out.
- Haskell is monadic. Meaning that it found a nice way out in a functional world that’s not supposed to accept side effects (I/Os being one big source of side effects that are hard to avoid).
There are a few other reasons for me to be interested in Haskell but these are the main ones. So I’ll go through some tutorials and see where these lead me. I have a small pet project that I’d like to implement in Haskell so the goal for me is really to write code and not only to read a few documents. I’ll let you know along the way what I find interesting, exciting or irritating and pass along a few tips.
Matthieu Riou on November 28th 2007 in Uncategorized
Matt Russell responded on 28 Nov 2007 at 11:26 am #
I’ve spent a bit of time over the last couple of months learning Haskell, and it’s been pretty fun. You’re right that it’s an academic language, and not least in the culture around it, which is very theoretical-CompSci oriented. Because of this, my feeling is that Haskell itself will likely only ever influence mainstream commercial software development indirectly (and it already has, to some extent: e.g. Java generics and Python list comprehensions). That’s not necessarily a bad thing, though.
I thought Djinn was particularly cool: it’s a tool that can generate all the code you need for a function from its type declaration alone. Obviously it can’t always do this, but it’s still, well, interesting.
http://lambda-the-ultimate.org/node/1178
If you find videos a useful way to learn, I found these lectures quite helpful; the first 10 or so are about Haskell programming specifically:
http://video.s-inf.de/#FP.2005-SS-Giesl.(COt).HD_Videoaufzeichnung
(The lecture videos are 2005-SS-FP.V01 to 2005-SS-FP.V26)
Max responded on 29 Nov 2007 at 6:22 am #
Lazy (infinite) lists *are* useful. Hughes’s “Why Functional Programming” shows how useful (perhaps even essential) lazy evalution is for modularising dataflow.
David Thompson responded on 29 Nov 2007 at 6:30 am #
If your serious then forget the online tutorials and buy
http://www.cs.nott.ac.uk/~gmh/book.html
lucid and terse.
Cale Gibbard responded on 29 Nov 2007 at 7:09 am #
Welcome to Haskell!
If you haven’t already joined us in #haskell on irc.freenode.net, make sure that you do! It’s very beginner friendly, and asking questions there is often the quickest way to learn things or get help if you’re having trouble getting something to compile.
Paul Brown responded on 29 Nov 2007 at 1:02 pm #
I think you’ll enjoy it. The Ruby Quiz problems are one nice place to start, although some are more suited to initial functional explorations than others. In addition to the usual wiki pages, the Zvon reference, and the haskell-cafe list, you should check out the “Real World Haskell” book (http://www.realworldhaskell.org/blog/book/).
Jon Harrop responded on 29 Nov 2007 at 7:41 pm #
Haskell will certainly teach you a lot but mostly about how to work around purity, e.g. monads and zippers.
You might also like to look at OCaml and F#. They are much more widely used in industry and have a lot of useful features not found in Haskell.
Matthieu Riou responded on 29 Nov 2007 at 8:57 pm #
Thanks to all of you for the various hints!
@david, I was actually looking for a book to start with but the Amazon reviews didn’t quite convinced me. I might reconsider.
@cale, thanks for the invite, I’ll surely do.
@paul, the book seems to still be in its early stage but I’ll follow their blog.