假设我有以下(错误的)代码。
data A a b where
APure :: (A a b)
AApply :: A (A b c) c
test :: (A a b) -> a -> b
test (APure) a = a
test AApply a = undefined
然后 GHC 会给我这个错误:
Couldn't match type `b' with `A b1 b'
`b' is a rigid type variable bound by
the type signature for test :: A a b -> a -> b
Inaccessible code in
a pattern with constructor
AApply :: forall c b. A (A b c) c,
in an equation for `test'
In the pattern: AApply
In an equation for `test': test AApply a = undefined
这个错误信息不是完全错误的吗?该错误与 AApply 无关。