【发布时间】:2017-07-17 18:46:49
【问题描述】:
我正在尝试在 Idris 中编写一条记录,但它有一个需要受接口约束的通用参数。对于普通的联合类型,我可以写:
data BSTree : (a : Type) -> Type where
Empty : Ord a => BSTree a
Node : Ord a => BSTree a -> a -> BSTree a
但我试图找出做同样事情的语法,只是用一个记录。我试过类似的东西:
record Point a where
constructor MkPoint : Eq a => a -> a -> Point a
x : a
y : a
但它不会编译。
有没有办法在 Idris 中做到这一点?
TIA
【问题讨论】: