Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 8371475

Browse files
committed
Use hoistTerm to generalize monotypes to polytypes.
1 parent 29fc72f commit 8371475

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

semantic-core/src/Analysis/Typecheck.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ forAlls ns body = foldr forAll body ns
8080
generalize :: (Carrier sig m, Member Naming sig) => Term Monotype Meta -> m (Term (Polytype :+: Monotype) Gensym)
8181
generalize ty = namespace "generalize" $ do
8282
Gensym root _ <- Name.fresh
83-
pure (Gensym root <$> forAlls (IntSet.toList (mvs ty)) (fold ty))
84-
where fold :: Term Monotype a -> Term (Polytype :+: Monotype) a
85-
fold = \case
86-
Var v -> Var v
87-
Term t -> Term (R (hmap fold t))
83+
pure (Gensym root <$> forAlls (IntSet.toList (mvs ty)) (hoistTerm R ty))
8884

8985

9086
typecheckingFlowInsensitive :: [File (Term Core.Core Name)] -> (Heap Name (Term Monotype Meta), [File (Either (Loc, String) (Term (Polytype :+: Monotype) Gensym))])

0 commit comments

Comments
 (0)