2

trying to have 2 executables in my properly named 'MyFirstProject'

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

(MyFirstProject is a library inside this same project, but it's completely irrelevant)

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

stack build fails, because my hello's module isn't called Main:

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

it is correct - given the tree above, the module is named Hello.Main:

module Hello.Main where

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

but, of course, if I were to call it Main, I will get the expected:

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

feels like catch 22, eh? I can't call the module Main AND place it at the root of app/, because there's a default-generated one in there already (which builds no problem, if I comment the 'hello' one out)

alexakarpov
  • 1,848
  • 2
  • 21
  • 39
  • 1
    See https://stackoverflow.com/questions/50659327/stack-build-results-in-output-was-redirected-with-o-but-no-output-will-be-gen/50659706#50659706 – Stéphane Laurent Jun 27 '19 at 02:02
  • never mind the previous comment, it worked - I didn't realize I need to get in the 2nd of two states listed for this workaround to take effect – alexakarpov Jun 27 '19 at 02:24

0 Answers0