Cabal:找不到可执行test1的'Main-Is'字段

时间:2014-05-11 21:34:58

标签: haskell main cabal

我正试图用cabal运行一个非常简单的“Hello World”项目。

这是我保存项目的文件夹(ubuntu)

mtt@mttPC:~/Documents/Haskell/test1$ ls
dist          Greetings.o  Setup.hs  test1.cabal

Main.hs包含:

module Greetings where

main :: IO ()
main = print "hello"

Hello world确实有效:

mtt@mttPC:~/Documents/Haskell/test1$ runhaskell Main.hs configure --ghc
"hello"

test1.cabal文件已使用cabal init生成:

-- Initial test1.cabal generated by cabal init.  For further documentation,
--  see http://haskell.org/cabal/users-guide/

name:                test1
version:             0.1.0.0
-- synopsis:            
-- description:         
-- license:             
license-file:        LICENSE
author:              mtt
maintainer:           
-- copyright:           
-- category:            
build-type:          Simple
cabal-version:       >=1.8

executable test1
  -- main-is: Main.hs     
  -- other-modules:     
  build-depends:       base ==4.6.*

我不明白为什么:

mtt@mttPC:~/Documents/Haskell/test1$ cabal configure
Resolving dependencies...
Configuring test1-0.1.0.0...

Error: No 'Main-Is' field found for executable test1

1 个答案:

答案 0 :(得分:5)

您忘记取消注释告诉GHC要构建哪个模块作为主要入口点的文件

...
executable test1
  main-is: src/Main.hs -- Or whatever is appropriate
  build-depends: base==4.6.*
相关问题