小编Joh*_*ith的帖子

类型变量'a0'是不明确的

我不明白为什么下面的代码不会编译:

{-# LANGUAGE GADTs, ScopedTypeVariables #-}

data A = A

class C a where
  c :: a -> Bool

instance C A where
  c _ = True

data D a where
  D :: C a => D a

toBool :: D a -> Bool
toBool D = c (undefined::a)
Run Code Online (Sandbox Code Playgroud)

这是错误消息:

Could not deduce (C a0) arising from a use of ‘c’
from the context (C a)
  bound by a pattern with constructor
             D :: forall a. C a => D …
Run Code Online (Sandbox Code Playgroud)

haskell

7
推荐指数
1
解决办法
996
查看次数

标签 统计

haskell ×1