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

Coerce format descriptions into representation types #355

Merged
merged 1 commit into from
Jan 18, 2023

Conversation

brendanzab
Copy link
Member

@brendanzab brendanzab commented May 3, 2022

This PR adds implicit coercions from format descriptions into their representation types during elaboration, removing the need to explicitly call Repr in most cases. This would almost bring us full circle back to when I was trying to use subtyping in Fathom, but now the subtyping would be kept out of the core language, greatly reducing the confusing complications that resulted from conflating types and format descriptions.

Introducing this style of coercive subtyping during elaboration is also not entirely unheard of either: it is a common addition for elaborators to type theories with Tarski-style universes, which seem to have a connection to our approach to format descriptions.

Drawbacks

By inserting calls to Repr implicitly, people learning Fathom could end up finding it harder to understand the difference between format descriptions and host representation types. Repr might also show up in error messages, and this could also result in confusion if people using Fathom aren't used to being explicit about converting between them. We could try to remove the explicit Repr calls during distillation, but would most likely be an imperfect process and could further exacerbate confusion when they do eventually appear.

Introducing subtyping could also make unification more difficult. I don't think this is too much of an issue for this limited use case, but I still don't fully understand the implications or potential interactions. We also probably want to add more subtyping in the future, for example as a way make refinement types usable (coercing from refined to non-refined terms), so we’ll probably have to deal with this anyway down the line.

Resources

When implementing this, I was inspired a bit by elaboration-zoo/experiments/univ-lifts's coe function.

@mikeday
Copy link
Contributor

mikeday commented May 3, 2022

That looks convenient!

@brendanzab brendanzab changed the title Implement coercions from format descriptions into representation types Coerce format descriptions into representation types May 3, 2022
@brendanzab brendanzab force-pushed the format-coercions branch 3 times, most recently from d92fd76 to 6b8bcc2 Compare May 12, 2022 04:29
Coerce format desciptions into their representation types by applying
`Repr` as required.
@brendanzab brendanzab marked this pull request as ready for review January 17, 2023 06:35
@brendanzab
Copy link
Member Author

Thinking I might merge this - we can always remove it if it’s too confusing.

@brendanzab brendanzab merged commit c55a19c into yeslogic:main Jan 18, 2023
@brendanzab brendanzab deleted the format-coercions branch January 18, 2023 03:45
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.

None yet

2 participants