Hakyll Beginnings

hakyll, programming

Compilation:

Compiling took 4.8 seconds, and the binary is 38MB!

time ghc --make  site.hs
[1 of 1] Compiling Main             ( site.hs, site.o )
Linking site ...
ghc --make site.hs  4.28s user 0.51s system 99% cpu 4.823 total

It turns out that ghc does static linking to hakyll and its dependencies by default. This is nice in that it creates a more portable binary, but the cost of compile time is too large. Dynamic linking can be enabled in ghc with the dynamic flag. However, cabal installed packages seem to not support this by default:

 site.hs:19:8:
     Could not find module `Hakyll'
     Perhaps you haven't installed the "dyn" libraries for package `hakyll-3.4.1.0'?
     Use -v to see a list of the files searched for.

This requires a simple rebuild to support dynamic linking.

cabal install --reinstall --enable-shared hakyll

You might have to also reinstall other cabal dependencies, or just start over as I did.

Finally,

time ghc --make  -dynamic site.hs
[1 of 1] Compiling Main             ( site.hs, site.o )
Linking site ...
ghc --make -dynamic site.hs  1.10s user 0.13s system 98% cpu 1.257 total

It was almost 4 times faster, and the binary is now only 116kB. Success.

val processor = new StreamingTransform {
  def transform(record: Element) = {
    val id = XQueryUtil.xquery(record, "IndexCatalogueID").get(0)
    val placeResults = XQueryUtil.xquery(record, "//Place")
    val places = (0 until placeResults.size) map placeResults.get

    println(id.getValue + " " + places.map(_.getValue).mkString(", "))
    new Nodes()
  }
}

Recent posts

Tag

cycling hacking hakyll personal programming running