TLDR: Is it possible to use module re-exports to avoid having "expose" all testable modules?
I've used something similar to the Chris Done template for my Haskell project. My ventureforth.cabal
file has the following sections:
library
hs-source-dirs: src
exposed-modules: VForth,
VForth.Location
build-depends: base >= 4.7 && < 5
ghc-options: -Wall -Werror
default-language: Haskell2010
executable ventureforth
hs-source-dirs: app
main-is: Main.hs
build-depends: base >= 4.7 && < 5,
ventureforth -any
ghc-options: -Wall -Werror -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010
test-suite ventureforth-test
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Spec.hs
build-depends: base >= 4.7 && < 5,
ventureforth -any,
doctest >= 0.9 && < 0.11,
hspec -any
ghc-options: -Wall -Werror -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010
My code is laid out as
ventureforth/
|
+- ventureforth.cabal
+- app/
| |
| +- Main.hs
|
+- src/
| |
| +- VForth.hs
| +- VForth/
| |
| +- Location.hs
|
+- test/
| |
| +- Spec.hs
| +- VForth
| |
| +- LocationSpec.hs
I've set up VForth.hs
to re-export VForth.Location
module VForth (
module VForth.Location
) where
import VForth.Location
And in the VForth.LocationSpec
unit-test I need only import VForth
to test the Location
type.
However unless I add add VForth.Location
to the list of "exposed modules" I encounter linker errors when trying to run cabal test
.
I had thought exposing a single module, VForth
, which re-exported all other modules, would have sufficed. Am I really stuck in the situation of having to list every single source file in cabal?