Producing multiple executables from single project

元气小坏坏 提交于 2019-12-03 00:09:44

cabal expects the module of the executable to be Main. You should skip the module line or use module Main where.

Ok here is the possible reason. The executable of a haskell program is not produced when the module is not Main when you actually compile the program. The main function of the Main module is used when the executable is run. A possible workaround for ghc is -main-is flag. So you can have something like

name:               my-amazing-project
version:            0.1.0.0
build-type:         Simple
cabal-version:      >=1.8

executable first-executable
  hs-source-dirs:   src
  main-is:          FirstExecutable.hs
  ghc-options:      -O2 -threaded -with-rtsopts=-N -main-is FirstExecutable
  build-depends:    base == 4.5.*

executable second-executable
  hs-source-dirs:   src
  main-is:          SecondExecutable.hs
  ghc-options:      -O2 -threaded -with-rtsopts=-N -main-is SecondExecutable
  build-depends:    base == 4.5.*
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!