Skip to content
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

Generic coercion code #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Generic coercion code #19

wants to merge 1 commit into from

Conversation

CohenCyril
Copy link
Collaborator

@CohenCyril CohenCyril commented Jan 17, 2024

This code replaces the specific code to generate coercions with a named based version.
The cons: it is specialized to one universe 😬
The pros: it is very generic (it supports arbitrary nesting), generates/relies on coercions and will support extensions of the hierarchy out of the box: it might also be used in future versions of HB if it does the job.

CC @ecranceMERCE @amahboubi

@amahboubi
Copy link
Collaborator

@CohenCyril what do you mean by "it is specialized to one universe"
?

@CohenCyril
Copy link
Collaborator Author

CohenCyril commented Feb 9, 2024

The code automatically generates coercions from a record $R_1$ to a record $R_2$ whenever the names of the fields of $R_2$ is a subset of the names of $R_1$ (e.g. given Record R1 := {a : X, b : Y}. Record R2 := {a : X}, we generate automatically a function of type R1 -> R2 solely based on the naming).
However this code works if and only if the designated records depend exactly on one universe variable.

@CohenCyril
Copy link
Collaborator Author

PS: This is not a problem for the current use cases because we indeed have exactly one universe variable in our hierarchy.

% there is a projection Proj1 with the same name Name
% and a coercion from Proj1 to Proj2.
% - Depth is the number of (common) parameters between Rec1 and Rec2.
% Limitation: GR1 and GR2 have exactly one universe.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I documented here the limitation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants