[Haskell-cafe] how do cabal internal libraries work?

Evan Laforge qdunkan at gmail.com
Wed May 23 22:09:47 UTC 2018


The example at
https://www.haskell.org/cabal/users-guide/developing-packages.html#library
doesn't seem to work as I expect.  The doc for the library field is out of
date, but if you scroll down it mentions "internal libraries".  But
depending on the internal library doesn't seem to have any effect, in that
cabal still complains I didn't mention Foo.Internal, and doesn't see the
build-depends from it.  Am I misinterpreting how the feature is supposed to
work?

This is with Cabal 2.2.0.1 and cabal-install 2.2.0.0, ghc 8.4.1:

% cat testing.cabal
name:           foo
version:        1.0
license:        BSD3
cabal-version:  >= 1.23
build-type:     Simple

library foo-internal
    exposed-modules: Foo.Internal
    build-depends: base, text

library
    exposed-modules: Foo.Public
    build-depends: foo-internal, base

% cat Foo/Internal.hs
module Foo.Internal where
import Data.Text

% cat Foo/Public.hs
module Foo.Public where
import Foo.Internal

% cabal build
Resolving dependencies...
Configuring foo-1.0...
Warning: Packages using 'cabal-version: >= 1.10' must specify the
'default-language' field for each component (e.g. Haskell98 or Haskell2010).
If a component uses different languages in different modules then list the
other ones in the 'other-languages' field.
Preprocessing library 'foo-internal' for foo-1.0..
Building library 'foo-internal' for foo-1.0..
[1 of 1] Compiling Foo.Internal     ( Foo/Internal.hs,
dist/build/foo-internal/Foo/Internal.o )
[1 of 1] Compiling Foo.Internal     ( Foo/Internal.hs,
dist/build/foo-internal/Foo/Internal.p_o )
Preprocessing library for foo-1.0..
Building library for foo-1.0..

<no location info>: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal
file's other-modules: Foo.Internal
[1 of 2] Compiling Foo.Internal     ( Foo/Internal.hs,
dist/build/Foo/Internal.o )

Foo/Internal.hs:2:1: error:
    Could not find module ‘Data.Text’
    Use -v to see a list of the files searched for.
  |
2 | import Data.Text
  | ^^^^^^^^^^^^^^^^
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180523/f0975701/attachment.html>


More information about the Haskell-Cafe mailing list