我试图弄清楚为什么类型检查器会拒绝这个:
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
没有可用的实例
嗯,赐教我:)