查看讨论
here
和帕哈迪
bound-extras
package here
.
要点是类型抽象是一个术语级的东西(因此是
Expr
)这需要抽象
Type
S.平原
Scope b f a
不适合处理这个问题,因为它的扩展
f (Either b (f a))
有
f
两次均已修复。你想要外面的
f
是一个
EXPR
,而内部应该是
类型
.这就导致了
Scope
:
newtype ScopeH b f g a = ScopeH (g (Either b (f a)))
newtype ScopeT b t f a = ScopeT (t f (Either b (f a)))
newtype Expr' a b = Expr' (Expr b a)
data Expr b a
= V a
...
| TyApp (Expr b a) (Ty b)
| Forall (ScopeH () (Expr' a) Ty b)
...
Expr' a
修复术语vars的de bruijn索引,以便
ScopeH
构造函数可以引入一个要放入的附加类型var
b
洞。