Eric Warmenhoven

Friday, September 1, 2006


5:00 pm

All I have to say is, damn you Evan.

Back when I was in college (six years ago), I took CS 162, “Programming Languages”, which was a required course but I would have taken it anyway. Most of what I remember focused on explaining the features of the languages we already knew (Java and C++) and explaining that things didn’t have to be that way. They introduced Generic Java (I hear generics have been added to Java now) and had us write several programs using generics, which was about the only language that we actually had to program in. But they also made us use Haskell.

As I recall, the assignment in Haskell was to write a B-tree. We didn’t have to compile anything; we just wrote a small file and loaded it in hugs and ran commands in the interpreter. It actually ended up being really easy, which left a favorable impression of Haskell in my mind, but I never learned more about Haskell. Instead I went off and learned C by hacking gaim. And look where that got me.

Anyway, over the last year or so, Evan Martin has written about Haskell fairly frequently, and every time he does, it brings back fond memories of my earlier Haskell programming experience.

And two weeks ago, I finally decided to do something about it. I downloaded hugs and GHC and read a lot of documentation, and wrote a lot of test programs. This time, with the aid of GHC, I actually compiled an executable. And it was fantastic. Suddenly Haskell became a real language for me. Though it took a lot of reading first to figure out how to get the list of command line arguments, and then to understand how the IO Monad works so that I can actually use the getArgs function without screaming.

So here I am, a Haskell newbie coming from a C world, trying to make sense of it all. And naturally, I have questions.

  • Where did all the shared libraries go? Turning a Haskell module into a static library looks like it’s fairly straightforward, but it looks like it’s impossible to create a shared library that’s usable by other Haskell programs.
  • Why do header files have a bizzare suffix? If module A uses something from module B and module B uses something from module A, there’s a circular dependency that GHC can’t resolve on its own. The solution to this is to create a “boot” copy of module A that defines the things that B depends on without depending on B. In C this is called a header file. In GHC this is called a boot file and is given the extension “.hs-boot”.
  • Why does everyone ignore all the practical stuff? I read through five tutorials before I finally found one (on Monads, of all things) that actually had a usable getArgs example.
  • Where’s the Debian-specific documentation? For example, there’s a GTK module. Where is that? How do I get it? Is there a package for it? If not, how do I make one? (I saw the debian haskell mailing list but didn’t feel like wading through the archives hoping that one of my questions might be answered.)

3 Responses to “Monadic”

  1. Antti-Juhani Kaijanaho Says:

    Some short responses in my blog. Please note that a mailing list is a better place for these questions :)

  2. Liyang HU Says:

    I’m taking care of the Gtk2Hs Debian packages. It will end up in Debian proper soon enough. (It’s a pending upload.) This repository however will always have the latest/experimental revision(s).

  3. John Goerzen Says:

    I’ve also written some answers for you on my blog.