我开始一个新的堆栈项目,stack new demo
并在应用程序文件夹中定义了第二个文件Other.hs
。没有依赖关系,只是:
module Other where
main :: IO ()
main = print 4
在package.yaml
下面executables
我添加
other-exe:
main: Other.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- debug-multiple-files
现在当我这样做时,stack build
我得到:
<no location info>: error:
output was redirected with -o, but no output will be generated
because there is no Main module.
所以我添加-main-is
到 ghc-options:
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
- -main-is Other
现在stack build
可以工作了,但是在stack-ghci
选择我得到的可执行文件之一之后,
<no location info>: error:
module ‘main:Main’ is defined in multiple files: /home/.../demo/app/Main.hs
/home/.../demo/app/Main.hs
Failed, no modules loaded.