Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
haskell堆栈:要加载的主模块不明确_Haskell_Ghci_Haskell Stack - Fatal编程技术网

haskell堆栈:要加载的主模块不明确

haskell堆栈:要加载的主模块不明确,haskell,ghci,haskell-stack,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.

我有多个名称不冲突的可执行文件。然而
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
如何使
堆栈ghci
加载所有这些不冲突的模块

完整的阴谋集团档案:

$ 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
$cat ambig.cabal
姓名:ambig
版本:0.1.0.0
构建类型:简单
阴谋集团版本:>=1.10
可执行苹果
hs源目录:src
主要是:Apple.hs
ghc选项:-主要是Apple.Apple
默认语言:Haskell 2010
构建取决于:基础>=4.7&<5
可执行香蕉
hs源目录:src
主要是:香蕉
ghc选项:-主要是香蕉。香蕉
默认语言:Haskell 2010
构建取决于:基础>=4.7&<5

我也有同样的问题,如果我将我在我的项目中所做的转换到您的项目中,您应该能够执行以下任一操作来选择主模块:

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


这是预期的行为,因为堆栈当前没有任何魔法来解析ghc选项之外的内容。我已经打开了跟踪增强。
stack ghci --main-is ambig:exe:banana