[Haskell-cafe] How to use cabal's data-files feature and run in-place?

Richard Cobbe cobbe at ccs.neu.edu
Fri Apr 22 03:46:00 CEST 2011


I'm running Haskell Platform 2011.2.0.1 on a MacOS 10.6.7 machine (the
machine is 64-bit, but I'm running the 32-bit platform).

I'm writing an application for personal use, and I'd like to use Cabal to
package it up and handle installation.  This way, when I'm working on the
program, I won't break the reasonably stable installed version and can
continue to use it.

(I'm not committed to cabal by any means; suggestions for other ways to
accomplish the same thing are more than welcome!)

I've got some data files I'd like to package with the application, and
Cabal's data-files field is the obvious way to do that.  The immediate
problem, then, is how to access the files -- I can use the generated
Paths_pkg module for the "installed" copy of the app, but then I can't run
the thing in-place in ghci in the development directory.

I did some googling and came across a blog post
(http://neilmitchell.blogspot.com/2008/02/adding-data-files-using-cabal.html)
which suggested that I provide my own Paths_pkg.hs file that points to the
files' location in the development copy.  When I build with Cabal, the
generated form of this module would override my hand-written one, and it
should therefore work in the installed case as well.

Unfortunately, that's not happening.  Cabal is clearly generating the
module; I can see it in dist/build/autogen.  But my copy is overriding the
autogenerated one, even for cabal builds -- at least, that's what I'm
seeing when I run the binary out of dist/build/<package>/<executable>.

Is there a way to be able to use data files in both contexts?

FWIW, I'm running cabal as

    runhaskell Setup.hs configure --user
    runhaskell Setup.hs build

Thanks much,

Richard



More information about the Haskell-Cafe mailing list