feat: polymorphic type class members

This commit is contained in:
Shunsuke Shibayama 2023-07-14 01:53:06 +09:00
parent f65e3acaf3
commit e3b479ebf7
12 changed files with 247 additions and 48 deletions

View file

@ -41,6 +41,9 @@ impl Generalizer {
fn generalize_tp(&mut self, free: TyParam, uninit: bool) -> TyParam {
match free {
TyParam::Type(t) => TyParam::t(self.generalize_t(*t, uninit)),
TyParam::Value(ValueObj::Type(t)) => {
TyParam::t(self.generalize_t(t.into_typ(), uninit))
}
TyParam::FreeVar(fv) if fv.is_generalized() => TyParam::FreeVar(fv),
TyParam::FreeVar(fv) if fv.is_linked() => {
self.generalize_tp(fv.crack().clone(), uninit)
@ -122,7 +125,7 @@ impl Generalizer {
TyParam::unary(op, val)
}
other if other.has_no_unbound_var() => other,
other => todo!("{other}"),
other => todo!("{other:?}"),
}
}