-runInfer i = uncurry closeOver <$> evalStateT i [0..]
-where
- closeOver :: Subst Type -> Scheme
- closeOver sub ty = normalize (generalize 'Data.Map'.newMap (apply sub ty))
-
- normalize :: Scheme -> Scheme
- normalize i = i
-// normalize (Forall ts body) = Forall (snd <$> ord) (normtype body)
-// where
-// ord = zip2 (removeDup $ fv body) (fmap letters)
-//
-// fv (TVar a) = [a]
-// fv (TFun a b) = fv a ++ fv b
-// fv _ = []
-//
-// normtype (TFun a b) = TFun (normtype a) (normtype b)
-// normtype (TCon a) = TCon a
-// normtype (TVar a) =
-// case lookup a ord of
-// Just x = TVar x
-// Nothing = Left ["type variable not in signature"]