module Main
alicebob :: String -> String
alicebob "alice" = "Hi alice"
alicebob "bob" = "Hi bob"
alicebob _ = "Hi person whose name is neither alice nor bob."
greet :: IO ()
greet = do
putStrLn "hi. whats your name?"
name <- getLine
putStrLn (alicebob name)
简单的编程练习,以获得一些用户输入和回复。刚开始学习haskell,所以请原谅这个简单的问题。在线
alicebob ::
String -> String
出现错误.我该如何解决?
最佳答案
模块头必须包含 where
,
module Main where
-- ^^^^^
编译器期望找到
where
(可能前面有一个导出列表)以及当它找到 alicebob
时相反,它会引发错误。
关于haskell - 为什么这个 [haskell] 编译错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19058941/