haskell Stack-一个具有多个可执行文件的项目

时间:2019-06-27 01:22:57

标签: haskell haskell-stack

试图在我名为“ MyFirstProject”的文件中拥有2个可执行文件

executables:
  run-it:
    source-dirs: app/
    main: Main.hs
    dependencies:
      MyFirstProject
  hello:
    source-dirs: app/Hello/
    main: Main.hs

(MyFirstProject是该项目内的一个库,但完全不相关)

± |master U:3 ?:2 ✗| → tree app/
app/
├── Hello
│   └── Main.hs
└── Main.hs

堆栈构建失败,因为我的hello的模块未称为Main:

<no location info>: error:
    output was redirected with -o, but no output will be generated
because there is no Main module.

这是正确的-给定上面的树,该模块名为Hello.Main:

module Hello.Main where

main :: IO ()
main = putStrLn "Hello, world"

但是,当然,如果我将其称为Main,我将得到预期的结果:

    File name does not match module name:
    Saw: ‘Main’
    Expected: ‘Hello.Main’
  |
1 | module Main where
  |        ^^^^

感觉像是抓住22,是吗?我无法调用模块Main并将其放置在app /的根目录下,因为其中已经有一个默认生成的模块(如果我将'hello'注释掉的话,这不会产生问题)

0 个答案:

没有答案
相关问题