我想用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
您忘记取消注释告诉GHC构建哪个模块作为主要入口点的文件
...
executable test1
main-is: src/Main.hs -- Or whatever is appropriate
build-depends: base==4.6.*