不在范围内:`catch' [英] Not in scope: `catch'
本文介绍了不在范围内:`catch'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在阅读,以了解您对haskell的极大兴趣,但是当我阅读输入&的异常部分时,我遇到了Not in scope:`catch'的错误.输出章节
I am reading learn you a haskell for great good but i faced an error of Not in scope: `catch' when I read the exception section in input & output chapter
这是我的代码:
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
这篇关于不在范围内:`catch'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文