[Haskell-cafe] Stupid question about Cabal file

Daniel Fischer daniel.is.fischer at web.de
Thu Jun 26 08:41:36 EDT 2008

Am Donnerstag, 26. Juni 2008 14:01 schrieb Fernand:
> Hi,
> Excuse me in advance if this is a trivial question, but I have been
> unable to find (understand?) the answer in Cabal's documentation.
> My issue is simple : I build a Cabal package named, let's say, "foo".
> That package is a library (libHSfoo.a, something like that), which
> exposes its Foo.Bar and Foobar modules. I wrote the cabal file, register
> it, everything seems fine.
> The issue comes when I try to use that package when compiling a main
> program, like this :
> ghc -package foo MyMain.hs [other options]
> I get an error about the compiler not finding the interface files
> Foobar.hi and Bar.hi, as I have "import Bar" and "import Foo.Bar" in my
> "MyMain.hs" file. Of course, I could add "-l" flags to point to the
> ".hi" files that I used to compile my package, but I get the well-known
> issue about the fact that the package's names of the interface files
> (which were compiled with the "-package-name foo" option) are not the
> correct ones ("Bad interface file: ../foo/Foobar.hi, Something is amiss;
> requested module  main:Foobar differs from name found in the interface
> file foo:Foobar") ; and that solution is ugly anyway.
> So far, I found some Cabal documentation talking about the import-dirs
> property, but I did not manage to "make it work", I mean, my package
> does not seems to "include" the interface files. I am sure, on the other
> hand, that it is possible :)
> Sincerely yours,
> Fernand

Did you create your package using Cabal, i.e. have a module Setup.(l)hs in the 
same directory as the .cabal file and then

runhaskell Setup.hs configure --prefix=WhereYouWantIt
runhaskell Setup.hs build
runhaskell Setup.hs haddock (optionally)
runhaskell Setup.hs install

Then you shouldn't even need the -package option to use it, ghc-pkg would know 
where to find the interface files.


More information about the Haskell-Cafe mailing list