9
$\begingroup$

What's a good approach for extending Hindley Milner with mutual recursion without de-sugaring to let+fix+records? My thinking is (assuming no polymorphic recursion)

  1. Collect mutually recursive lets together in a group.
  2. Add their bindings to an environment with fresh monotype type variables.
  3. Infer right-hand-side of let bindings, and if one of the bindings in the group is referenced, it just looks up the monotype typevar from the environment.
  4. After all bindings in the group have been checked, generalize the monotype typevars to polytypes, and replace the type in the environment.

Is this generalization sound?

$\endgroup$

0

You must log in to answer this question.

Browse other questions tagged .