一个玩具示例,但仍然令人沮丧:
numberMapper:: IO ()
numberMapper = do codes <- forM [1 .. 4] (\num ->
do putStrLn $ "Enter a code for " ++ show num
code <- getLine
return code)
let numberCodes = zip [1 .. 4] codes
in forM numberCodes (\(num,code) ->
putStrLn $ "Got code " ++ show code ++ " for " ++ show num)
ghci
告诉我我有一个Parse error in pattern: putStrLn
,但我不知道为什么它应该无法解析。