Haskell GHC can';t使用GADT和箭头确定类型相等

Haskell GHC can';t使用GADT和箭头确定类型相等,haskell,gadt,arrows,Haskell,Gadt,Arrows,我很难让GHC注意到箭头表达式中的两种类型是相等的 data PolyList a where Nil :: PolyList '[] Cons :: a -> PolyList as -> PolyList (a ': as) class Recurse a where method :: PolyList a -> String instance Recurse '[] where method _ = "" instance (Sho

我很难让GHC注意到箭头表达式中的两种类型是相等的

data PolyList a where
    Nil :: PolyList '[]
    Cons :: a -> PolyList as -> PolyList (a ': as)

class Recurse a where
    method :: PolyList a -> String

instance Recurse '[] where
    method _ = ""

instance (Show a, Recurse as) => Recurse (a ': as) where
    method = proc input -> case input of
        (Cons a as) -> do
            rest <- method -< as --Could not deduce (Recurse as)
            returnA -< show a ++ rest

    method = proc input -> case input of
        (Cons a as) -> do
            rest <- method -< as :: PolyList as --Works fine
            returnA -< show a ++ rest

    method (Cons a as) =
            let rest = method as --Also works
            in show a ++ rest
为什么它不能告诉
as
已经有了类型
PolyList as


编辑:不管怎么说,这都是无用的,因为修复程序似乎会触发,但仍未解决。如果您将有问题的行替换为
rest,那么最好了解问题所在。

Could not deduce (Recurse as) arising from a use of `method'
from the context (Show a, Recurse as1)
  bound by the instance declaration
Possible fix:
  add (Recurse as) to the context of the instance declaration