[Haskell-cafe] Re: Distributing a program with support files

Simon Marlow simonmarhaskell at gmail.com
Wed May 30 16:25:33 EDT 2007


Neil Mitchell wrote:
> Hi Duncan,
> 
>> 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
> 
> A few questions:
> 
> 1) How do I test this? I'll need to develop in Hugs and GHC without
> going through Cabal building. Should I fake up a Paths_<pkg> module?
> 
> 2) Is there any reasonable limit on the number of data files? Is 1000 
> too many?
> 
> 3) Can I create files in this DataDir directory?
> 
> It does seem that creating a new Paths_<pkg> module and include it is
> not very pleasant. It requires everyone to compile from source to get
> the paths working, which doesn't make much sense.

The idea is that you get to refer to your data files without any explicit paths, 
Cabal chooses where to install them, and it works on any OS.  Furthermore, on 
Windows you can generate a relocatable binary distribution, because Windows lets 
you put the files in a path relative to the binary.

The Cabal docs describe how to do it.  Also check out Happy, Alex and Haddock - 
they all have data files that come with the package.  Personally, I think it 
works nicely!

Cheers,
	Simon


More information about the Haskell-Cafe mailing list