New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor long tuples to records in typeclass.ml #8527
Conversation
All |
Next I would want to work on tuple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a nice start, thanks! Two related thoughts:
- Try to maximize the use of field punning - i.e. be allergic to writing
{ foo = bar }
if a rename can give{ foo }
instead - I would think for these new types (especially ones internal to a module) that we can drop the
clsres_
prefix on the field names and simply require a type annotation at the site. i.e. I think thatlet foo ({id; id_loc; clty} : 'a class_res) = …
is nicer thanlet foo {clsres_id; clsres_id_loc; clsres_clty} = …
and definitely nicer thanlet foo {clsres_id = id; clsres_id_loc = id_loc; clsres_clty = clty} = …
. I can't remember if this is something which used not to be possible or whether this kind of a prefixing is just our lpdwHungarian notation hangover from pre-Merlin days!
I think it's okay to have a small scope for a first PR on this topic; settling on record field names for this record and code style for those functions. We can have further PRs that deal with other functions later, even if that means changing the present record to break it in smaller pieces. I agree with @dra27's suggestions (drop the prefix and use punning as much as possible). |
(I'm happy to let @dra27 continue to drive the review for this PR, approving when satisfied with the state.) |
Sorry it took me so long; had a midterms week. Let me know what you think about the fix. Btw, I copied the pre-commit hook to my .git and configured my editor to automatically remove trailing whitespace. Thanks, @dra27 :-) |
This LGTM - it's an internal refactoring, so up to you if you'd like to push a |
That's a little internal refactoring. I'd say it would rather clutter |
We have an |
We don't need to put a label, e.g. |
Indeed, however you should also add the pr number:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an omission on our part to not have merged this PR earlier. I will rebase to fix the conflict, push and merge when the CI passes.
The following functions were migrated to a record: extract_type_decls, merge_type_decls, final_env, check_coercions
4d2d843
to
3faa589
Compare
Addressing issue #7927.
I refactored only four functions that take the same long tuple. (Short commits for easier reviewing)
Those four functions are
extract_type_decls
,merge_type_decls
,final_env
, andcheck_coercions
.The long tuple was replaced by a record type that I created
'a class_res
. The type's name and its fields' names should probably be changed.Should that type also be revealed in the interface file? Afaik,
'a class_res
is only used by those four functions internal to thetypeclass.ml
.