I have a project whose main cabal component is a library
library
hs-source-dirs: src
...
and which also defines
executable todo
if !flag(example)
Buildable: False
ghc-options: -Wall
cpp-options: -DGHCJS_BROWSER
default-language: Haskell2010
hs-source-dirs: example/todo
other-modules: TodoDispatcher
TodoStore
TodoComponents
main-is: Main.hs
Now if I try to type check one file I get the following error
Configuring react-flux-1.0.3...
EXCEPTION: types:
Could not find module ‘TodoDispatcher’
Use -v to see a list of the files searched for.
And if I do so from the command line I get
$ ghc-mod --ghcOpt=-v7 type example/todo/TodoViews.hs 29 28 not sandboxed
EXCEPTION: types:
Could not find module ‘TodoDispatcher’
Locations searched:
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/TodoDispatcher.hs
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/TodoDispatcher.lhs
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/TodoDispatcher.hsig
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/TodoDispatcher.lhsig
src/TodoDispatcher.hs
src/TodoDispatcher.lhs
src/TodoDispatcher.hsig
src/TodoDispatcher.lhsig
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/autogen/TodoDispatcher.hs
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/autogen/TodoDispatcher.lhs
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/autogen/TodoDispatcher.hsig
.stack-work/dist/x86_64-osx/Cabal-1.22.8.0/build/autogen/TodoDispatcher.lhsig
So it seems to ignore the hs-source-dirs
setting of the component which the current file I try to typecheck belongs to, and instead consider the one from the first component of the package, just like cabal repl would do by default
By default cabal repl loads the first component in a package.
How can I change that nice bit of global state ?