使类型检查器接受多态递归接口实现

时间:2017-08-11 17:14:41

标签: idris

我试图弄清楚为什么类型检查器会拒绝这个:

module Test

import Data.Vect
import Data.HVect

data Tree = Leaf | Branch (Vect n Tree)

data Garble : Tree -> Type where
  Farble : Garble Leaf
  Marble : HVect (map Garble children) -> Garble (Branch children)

Eq (Garble tree) where
  Farble == Farble = True
  (Marble comps1) == (Marble comps2) = comps1 == comps2 -- breaks here
  _ == _ = False

这是抱怨,因为它无法在Eq (HVect (map Garble children))实例的Marble案例中找到Eq的实例。我怀疑这是因为map表达式在界面解析之前没有减少,或者多态递归在某种程度上对此负责,例如:那个Eq (Garble tree') ...

tree' /= tree没有可用的实例

嗯,赐教我:)

0 个答案:

没有答案