Conversation
katrinafyi
reviewed
Jul 13, 2026
katrinafyi
left a comment
Collaborator
There was a problem hiding this comment.
My first thoughts are that I think the inference.ml should be split up. There's a few separate things happening inside there. Forgive any imprecision but my impression is that it's roughly...
- expression-level type unification
- intrinsic-level type scheme definition and instantiation (?)
- statement-level
- procedure-level including parameters
- big everything procedure inference
- concretisation back to Bincaml types
I won't direct you about details but you get the idea. It would also let you write module-level docs for each idea closer to the code.
Generally, I would also like to see more.. restrained use of single-letter module names and local opens where possible.
katrinafyi
reviewed
Jul 13, 2026
katrinafyi
reviewed
Jul 14, 2026
| let occurs_in a b = | ||
| let check = function | ||
| | Var t -> equal_tvar t a | ||
| | TypeConstr (ls, _) -> List.fold_left ( || ) false ls |
Collaborator
There was a problem hiding this comment.
Suggested change
| | TypeConstr (ls, _) -> List.fold_left ( || ) false ls | |
| | TypeConstr (ls, _) -> List.for_all Fun.id ls |
Co-authored-by: Kait <39479354+katrinafyi@users.noreply.github.com>
katrinafyi
reviewed
Jul 14, 2026
katrinafyi
left a comment
Collaborator
There was a problem hiding this comment.
I don't think it's possible to review this PR properly, so I am really just making sure that it's documented enough and organised enough.
This will be the last major round of comments.
Co-authored-by: Kait <39479354+katrinafyi@users.noreply.github.com>
Co-authored-by: Kait <39479354+katrinafyi@users.noreply.github.com>
Co-authored-by: Kait <39479354+katrinafyi@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This forms the skeleton of the hindley-milner type inference system. This comprises:
This is essentially:
This should be sufficiently general to represent anything we want.
I expect the current inference and elaboration to not cover the whole program structure yet.
Similarly it doesn't do anything special to make sure the polymorphic ops get typed, identifying type errors, or let-generalisation. It doesn't do much yet as everything comes in typed already from the frontend; that will need a refactor to not enforce typing immediately.
We still generally use online type propagation from variables to get types, over the explicit
typfield in each exprssion node; that will also need to be fixed in order to migrate to this system.