Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.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
Exception 哈斯凯尔错误:“;不明确类型变量“;例外情况:捕获;需要类型签名,但在哪里?_Exception_Haskell_Types - Fatal编程技术网

Exception 哈斯凯尔错误:“;不明确类型变量“;例外情况:捕获;需要类型签名,但在哪里?

Exception 哈斯凯尔错误:“;不明确类型变量“;例外情况:捕获;需要类型签名,但在哪里?,exception,haskell,types,Exception,Haskell,Types,我正在尝试将程序的错误处理转换为使用异常。我构建了一个REPL来控制我的模拟,其中我还处理错误: > repl :: Sim -> IO Sim > repl old_sim = do > new_sim <- E.catch (do line <- getLine > commands <- parseCommand line >

我正在尝试将程序的错误处理转换为使用异常。我构建了一个REPL来控制我的模拟,其中我还处理错误:

> repl :: Sim -> IO Sim
> repl old_sim = do
>     new_sim <- E.catch (do line <- getLine
>                            commands <- parseCommand line
>                            runCommands commands old_sim)
>                        (\err -> do putStrLn . show $ err
>                                    return old_sim)
>     if alive new_sim
>        then repl new_sim
>        else return new_sim
具体而言:

Probable fix: add a type signature that fixes these type variable(s)

我将在何处插入此类型签名?

错误时需要它来确定要捕获的异常

但是如果我将其添加为(\err::E.SomeException->…),我会得到“非法的结果类型签名`E.SomeException',模式匹配中不再支持结果签名”。您需要打开一些扩展才能在lambda中放置类型签名。但你可以把它放在任何错误的地方。Anm添加第一行
{-#语言范围TypeVariables}
@Anm啊,是的,正如我们刚才在IRC上所说的使用
(\(err::E.SomeException)->…)
Probable fix: add a type signature that fixes these type variable(s)