Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function inferLet(ctx: Context, expr: ELet): [Type, Substitution] {
- const [rhsType, s1] = infer(ctx, expr.rhs);
- const ctx1 = applySubstToCtx(s1, ctx);
- const rhsPolytype = generalize(ctx1.env, rhsType);
- const ctx2 = addToContext(ctx1, expr.name, rhsPolytype);
- const [bodyType, s2] = infer(ctx2, expr.body);
- const s3 = composeSubst(s1, s2);
- return [bodyType, s3]
- }
Add Comment
Please, Sign In to add comment