我正在阅读“向你学习 Haskell”,但当我阅读输入和输出章节中的异常部分时,我遇到了“不在范围内:‘catch’”的错误
这是我的代码:
import System.Environment
import System.IO
import System.IO.Error
main = toTry `catch` handler
toTry :: IO ()
toTry = do (fileName:_) <- getArgs
contents <- readFile fileName
putStrLn $ "The file has " ++ show (length (lines contents)) ++ " lines!"
handler :: IOError -> IO ()
handler e = putStrLn "Whoops, had some trouble!"
我收到此错误消息:
Not in scope: `catch'
最佳答案
catch
由 Control.Exception
模块导出。
import Control.Exception
关于haskell - 不在范围 : `catch' 内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42609508/