Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 例外情况的类型是什么;例外:前奏曲。阅读:无解析“;_Haskell_Exception Handling - Fatal编程技术网

Haskell 例外情况的类型是什么;例外:前奏曲。阅读:无解析“;

Haskell 例外情况的类型是什么;例外:前奏曲。阅读:无解析“;,haskell,exception-handling,Haskell,Exception Handling,我正在尝试捕获当用户写入与预期不同的内容时发生的异常 我正在这样做: main = do {catch (take_number) fix_error;} where take_number = do { take_number "Give me a number"; n <- readLn; } fix_error e = if Exception e then

我正在尝试捕获当用户写入与预期不同的内容时发生的异常

我正在这样做:

main = do
    {catch (take_number) fix_error;}
    where
        take_number = do
        {
            take_number "Give me a number";
            n <- readLn;
        }
        fix_error e = if Exception e then do
            {
                putStrLn "Invalid number! Try again";               
                main;
            }
            else ioError e
main=do
{catch(take_number)修复_错误;}
哪里
采取行动
{
拿着你的号码“给我一个号码”;

n执行
readLn
时得到的异常类型是,它只是

下面是处理错误的方法,我在
readLn
中添加了一个类型,以强制将其作为
Int
读取

导入控制。异常
main::IO()
main=捕捉器编号手柄错误
takeNumber::IO()
takeNumber=do
putStrLn“给我一个号码:”
n IO()
handleError e=do
putStrLn(“无效数字!请重试。错误为:++show e)
主要的

执行
readLn
时出现的异常类型是,它只是

下面是处理错误的方法,我在
readLn
中添加了一个类型,以强制将其作为
Int
读取

导入控制。异常
main::IO()
main=捕捉器编号手柄错误
takeNumber::IO()
takeNumber=do
putStrLn“给我一个号码:”
n IO()
handleError e=do
putStrLn(“无效数字!请重试。错误为:++show e)
主要的

如果异常e
如果异常e