
On Sun, 2007-05-27 at 14:36 +0100, Neil Mitchell wrote:
Hi,
I'm wanting to release a Haskell program, but am confused how I should distribute the associated files it needs. On Windows I would use the functions to find the path of the executable, and find the support files relative to that - in Haskell (because of Linux) that isn't the case.
The basic setup I have is:
foo.exe - main binary library.hs - required by the binary examples\*.hs - a massive tree of examples, which can be used by the binary
foo.exe also needs to create temporary files relative to library.hs and the examples.
list the support files in the "data-files:" stanza in the .cabal file. Then import the Paths_<pkg> module that Cabal generates for you. It exports a few functions including: getDataDir :: IO FilePath So if you listed: data-files: library.hs, examples\foo.hs, ... then you'd say dataDir <- getDataDir doSomething (dataDir > "library" <.> "hs" ) doSomething (dataDir > "examples" > "foo" <.> "hs" ) This should be portable between linux and windows (and everything else for that matter). Duncan