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)
- Collect mutually recursive lets together in a group.
- Add their bindings to an environment with fresh monotype type variables.
- 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.
- 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?
composeB
was a stupidforall a. (Bool -> Bool) -> (Bool -> Bool) -> Bool -> a
) $\endgroup$