I have multiple executables with non-conflicting names. Yet stack ghci
complains that the main module is ambiguous:
$ find . -type f -exec grep -Hi "apple\|banana" {} \; | grep -v work
./ambig.cabal:executable apple
./ambig.cabal: main-is: Apple.hs
./ambig.cabal: ghc-options: -main-is Apple.apple
./ambig.cabal:executable banana
./ambig.cabal: main-is: Banana.hs
./ambig.cabal: ghc-options: -main-is Banana.banana
./src/Apple.hs:module Apple (apple) where
./src/Apple.hs:apple :: IO ()
./src/Apple.hs:apple = putStrLn "I am apple"
./src/Banana.hs:module Banana (banana) where
./src/Banana.hs:banana :: IO ()
./src/Banana.hs:banana = putStrLn "I am banana"
$ stack ghci
The main module to load is ambiguous. Candidates are: [...]
$ stack --version
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e
How can I make stack ghci
load all these non-conflicting modules?
The complete cabal file:
$ cat ambig.cabal
name: ambig
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.10
executable apple
hs-source-dirs: src
main-is: Apple.hs
ghc-options: -main-is Apple.apple
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
executable banana
hs-source-dirs: src
main-is: Banana.hs
ghc-options: -main-is Banana.banana
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
I had the same problem, if I translate what I did on mine onto your project, you should be able to do either of these to choose the main module:
stack ghci --main-is ambig:exe:apple
or
stack ghci --main-is ambig:exe:banana
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.