Haskell hello world will not compile
这段代码有什么问题?试图做一个基本的哈斯克尔问候世界。Haskell hello world will not compile
module Main (hello)
where
hello :: [Char] -> [Char]
hello p = "Hello " ++ p ++ "!"
main =
let msg = hello "World"
putStrLn msg
回答:
你缺少一个do
:
main = do let msg = hello "World"
putStrLn msg
您还需要导出main
:
module Main (main) where
因为这是主要的模块,没有必要出口hello
。
回答:
你缺少一个in
:
main = let msg = hello "World" in putStrLn msg
以上是 Haskell hello world will not compile 的全部内容, 来源链接: utcz.com/qa/263107.html