Automating the Bunkplan (in Haskell)

Posted on May 26, 2012 by Jack Kelly
Tags: windeward_bound, coding

I had a working program for making the bunkplan and cabin sheets, but it was written in O’Caml. I need to make binaries that run on Windows and O’Caml’s Windows support is atrocious. Not only that, but somehow the font-locking of emacs’ ocaml-mode breaks font-lock in other modes. It wasn’t long before I gave up and ported the thing to Haskell just to use the Haskell Platform.

Most of the code ported over fairly easily, but I decided to generate HTML using the platform’s Text.Html library. Sadly, it suffers from a defect common to so many Haskell libraries: There’s a big list of types, type classes and functions, but no documentation on how the bits are expected to fit together. It defines operators (<<), (+++) and (!), where (<<) stuffs some html inside another tag, (!) adds attributes to a tag and (+++) concatenates html fragments. Nowhere does it say that, and that one sentence would’ve seriously reduce the time it took to get myhead around the library. When I previously ranted about autogenerated documentation, someone emailed me and said that in most cases a combination of function name, argument names and function type are usually enough. I don’t entirely agree - it seems to be true up to a certain threshold but falls down beyond that. This threshold appears to depend on the language; if the type system is less expressive (C, for example), the information in the type is easier to extract. When the type system is more expressive (Haskell), people build higher abstractions which means you hit the types-as-documentation threshold much sooner.

The code is in my repository, if you want to take a look.

Having finished the port, I realised that I’ve been solving the wrong problem. Everyone’s happy with the excel watchbill and the version my software makes hasn’t displaced it. (I didn’t even bother writing haskell code to make the watchbill.) It’s only sped up the generation of the cabin sheets - individual pages that list the occupants of one cabin (and are hung out the front of each cabin). Writing a program to make only cabin sheets will cut out about 99% of the input’s complexity, which means someone else can prepare them.

Previous Post
All Posts | RSS | Atom
Next Post
Copyright © 2024 Jack Kelly
Site generated by Hakyll (source)