Friday, November 06, 2009

Profiling + Template Haskell + Cabal

Cabal makes building, installing and distributing a Haskell program very easy.  Template Haskell makes writing cool pattern matching easy.  Profiling makes, well profiling easy.  But how can you do all these things together?  TH doesn't work well with profiling, so you need to compile twice.  Once with no profiling to make regular .hi and .o files.  Then again with profiling, renaming the .o and .hi files to .o_p and .hi_p in order to make it work.  With Cabal, you can basically do the same thing.  Compile once without profiling

runhaskell Setup.lhs configure --user
runhaskell Setup.lhs build
runhaskell Setup.lhs install

then again with the following additions to your cabal file, in the ghc-options section:


-prof
-auto-all
-osuf p_o
-hisuf p_hi

This should build the TH project with profiling support.

No comments:

Post a Comment