haskell-stack:加载的主要模块是模糊的

时间:2017-09-09 19:12:21

标签: haskell ghci haskell-stack

我有多个具有非冲突名称的可执行文件。然而stack ghci抱怨主要模块含糊不清:

$ 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

如何让stack ghci加载所有这些非冲突的模块?

完整的cabal文件:

$ 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

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,如果我将我所做的事情翻译到您的项目中,您应该可以选择其中的一个来选择主模块:

(+)

stack ghci --main-is ambig:exe:apple