我正在尝试编写一个简单的Haskell函数,读取文件内容,如果该文件存在,否则什么也不做。文件的哈斯克尔saferead
safeRead :: String -> IO()
safeRead path = readFile path `catch` handleExists
where handleExists e
| isDoesNotExistError e = return()
| otherwise = throwIO e
然而,这失败:parse error (possibly incorrect indentation or mismatched brackets)
为什么?我已经多次检查过缩进,而且我看起来都很好?
感谢澄清'|'的缩进,现在我知道:)也感谢“jsfiddle of haskell”链接。这会派上用场。 –