Musings about FP and CS

A log of my journey through FP and CS

Hakyll 4

by Clément Delafargue on January 17, 2013

Tagged as: haskell, hakyll, exherbo.

A few days ago, Hakyll 4 has been released.

The new features are:

  • Compiler is now a Monad and not an Arrow (which makes it a bit easier to fiddle with for most haskellers)
  • The templates are much more powerful
  • A new cleaner way to play with metadata
  • A check command to find broken links (very useful)

Since it was not yet updated in Exherbo, I’ve bumped its exheres. Easy task, right ? Well, I had to bump about 30 packages to make it build. In a way it shows how Haskell’s modularity enables programmers to focus on the core task by leveraging the power of a myriad of small, well designed libraries.

On the other hand, it shows how fast breakage can happen and how a little version requirement change for a minor version of a small dependency can lead to upgrading dozens of libraries.

Fortunately, there is an exlib allowing to quickly write an exheres for any package which is put on Hackage.

So, why go through the ordeal of repackaging Hackage for paludis ? Well I have to say it’s much more robust than Cabal. First, paludis handles multislot (several versions of a same program / lib) installed side-by-side, which is golden (no rvm, many cabal problems solved for free, …). It requires some work (not that much, thanks to the dedicated exlibs), but since everything is already defined in Cabal files, it’s not a showstopper. Another reason is that I really like to have all my packages centralized into one system instead of having five different package managers. Furthermore, thanks to the modular nature of paludis, it is perfectly possible to write an adapter to fetch packages directly from Hackage. There is an open ticket on that, but it’s a bit inactive, to say the least.

Anyway, after some work (again, with some help from Marc-Antoine), I’ve been able to make Hakyll 4 build on Exherbo. I still need to clean my commits before !pq-ing a patch.

[Update 18/01/2013] I’ve submitted my patch

The second step was to update the hakyll file. There have been some breakage between Hakyll 3 and Hakyll 4. The most visible changes are that compilers which were arrows have been turned into monads, and that data is injected in the templates via immutable contexts. The migration guide explains it in detail.

Marc-Antoine has ported his blog to Hakyll 4 and I’ve been able to shamelessly steal his work to port mine. I’ve fixed the remaining bits by looking at Jasper Van der Jeugt’s (the author of Hakyll) blog source code.

Once again, it’s been nice to play with Exherbo. Next step: multi-architecture and cross compiling, to have a decent system on my Raspberry Pi :)