Haskell你好世界不会编译

时间:2011-10-06 02:19:08

标签: haskell

这段代码有什么问题?试图做一个基本的haskell你好世界。

module Main
( hello )
where

hello :: [Char] -> [Char]
hello p = "Hello " ++ p ++ "!"

main =
  let msg = hello "World"
  putStrLn msg

2 个答案:

答案 0 :(得分:8)

您错过了do

main = do
  let msg = hello "World"
  putStrLn msg

您还需要导出main

module Main ( main ) where

由于这是主要模块,因此无需导出hello

答案 1 :(得分:7)

您错过了in

main = let msg = hello "World" in putStrLn msg