generalizeExistentials ported

This commit is contained in:
Paul Chiusano 2018-07-16 12:07:19 -04:00
parent 5644f47622
commit 3e11768fcf

View File

@ -445,13 +445,13 @@ annotateLetRecBindings letrec =
-- | Apply the context to the input type, then convert any unsolved existentials -- | Apply the context to the input type, then convert any unsolved existentials
-- to universals. -- to universals.
generalizeExistentials :: Var v => Context v loc -> Type v loc -> Type v loc generalizeExistentials :: Var v => Context v loc -> Type v loc -> Type v loc
generalizeExistentials ctx t = error "todo" generalizeExistentials ctx t =
-- foldr gen (apply ctx t) (unsolved ctx) foldr gen (apply ctx t) (unsolved ctx)
--where where
-- gen e t = gen e t =
-- if TypeVar.Existential e `ABT.isFreeIn` t if TypeVar.Existential e `ABT.isFreeIn` t
-- then Type.forall (TypeVar.Universal e) (ABT.subst (TypeVar.Existential e) (Type.universal e) t) then Type.forall (loc t) (TypeVar.Universal e) (ABT.substInheritAnnotation (TypeVar.Existential e) (Type.universal e) t)
-- else t -- don't bother introducing a forall if type variable is unused else t -- don't bother introducing a forall if type variable is unused
-- | Check that under the given context, `e` has type `t`, -- | Check that under the given context, `e` has type `t`,
-- updating the context in the process. -- updating the context in the process.