0
我已经写了一个电话本程序:哈斯克尔:putStrLn ploblem
import System.IO
main = do
putStrLn "Pls input the name: "
handle <- openFile "phone.txt" ReadMode
contents <- hGetContents handle
name<-getLine
putStrLn . findNumber name $ toDict contents
findNumber x [] = "not found"
findNumber x ((y,z):ys) = if x==y then z else findNumber x ys
toDict :: String -> [(String, String)]
toDict = map read . lines
我得到了一个错误,当我编译它。
phoneNumber.hs : 7:16: parse error on input '<-'
这里有什么问题?
indentation?注意源代码中的标签。将它们转换为空格并检查对齐。 – d8d0d65b3f7cf42