相关疑难解决方法(0)

模糊类型变量错误消息

我不认为这是一个错误,但我有点困惑,为什么这不起作用.一个额外的问题是它为什么提到变量e?没有变量e.

    Prelude> :m +Control.Exception
    Prelude Control.Exception> handle (\_-> return "err") undefined

    <interactive>:1:0:
        Ambiguous type variable `e' in the constraint:
          `Exception e'
            arising from a use of `handle' at <interactive>:1:0-35
        Probable fix: add a type signature that fixes these type variable(s)
    Prelude Control.Exception> 

显然它在ghci 6.8中工作正常,我使用的是6.10.1.

编辑:我已经最小化了代码.我希望在6.8和6.10中都能得到相同的结果

class C a                                                                                                     

foo :: C a => (a -> Int)-> Int                                                                                
foo _ = 1                                                                                                     

arg :: C a => a -> Int                                                                                        
arg _ = 2                                                                                                     

bar :: Int                                                                                                    
bar = …
Run Code Online (Sandbox Code Playgroud)

haskell type-inference typeclass

22
推荐指数
2
解决办法
4956
查看次数

标签 统计

haskell ×1

type-inference ×1

typeclass ×1