[Haskell-cafe] Cabal, lib and exe in one

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Tue May 1 07:02:18 EDT 2007


On Tue, 2007-05-01 at 09:34 +0100, Magnus Therning wrote:
> I'm trying to create a single cabal file containing specs for both a
> library and an executable using that library.  I'm not having much luck
> though :(
> 
> This is what I have so far:
> 
>   name: foo
>   version: 0.1
>   exposed-modules: Foo.Bar
>   other-modules: Foo.Qux Foo.C2HS
>   hs-source-dirs: src
>   include-dirs: csrc
>   c-sources: csrc/qux.c
>   extensions: ForeignFunctionInterface
>   build-depends: base, haskell98
>   
>   executable: foo
>   hs-source-dirs: test-src
>   main-is: foo.hs
>   other-modules: Foo.Bar
> 
> When built this is the message I get:
>   test-src/foo.hs:5:7:
>       Could not find module `Foo.Bar':
>         Use -v to see a list of the files searched for.
> 
> How do I specify that Foo.Bar is found where cabal puts it
> (./dist/build/)?

But surely Foo.Bar is in src, it is afterall exactly the same module as
the one you're using in the library, no?

So if foo.hs is in test-src and Foo/Bar.hs is in src then I think you
just need:

hs-source-dirs: test-src, src

You cannot specify that things are found in dist/build since that dir
can placed anywhere by the user. But I don't see that you'd want to, I
can't see how it makes any sense.

Duncan



More information about the Haskell-Cafe mailing list