這段代碼有什麼問題?試圖做一個基本的哈斯克爾問候世界。Haskell hello world will not compile
module Main
(hello)
where
hello :: [Char] -> [Char]
hello p = "Hello " ++ p ++ "!"
main =
let msg = hello "World"
putStrLn msg
這段代碼有什麼問題?試圖做一個基本的哈斯克爾問候世界。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
。
或者,離不開:'主= putStrLn(你好 「世界」)' –
或'主要= $ putStrLn你好 「世界」' – pat
或'主要= (putStrLn。hello)「World」' – Ingo