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

Possible roadmap feature: Implement subtypes #140

Open
gwhitney opened this issue Mar 25, 2022 · 1 comment
Open

Possible roadmap feature: Implement subtypes #140

gwhitney opened this issue Mar 25, 2022 · 1 comment

Comments

@gwhitney
Copy link
Collaborator

This is a placeholder to not lose track of some discussion in other issues that typed-function could allow clients to declare one type is a subtype of another.

Potential advantages of this include:

  • reduce redundancy in type checking/number of type checks (there is no need to reiterate the supertype check in the subtype, the infrastructure will do it for you; and if the supertype check fails, there is no need to test any of its subtypes).
  • typed-function can reorder the type checks to avoid "missing" a type because a more inclusive check happens to get ordered before a less inclusive one; hence proper operation of typed-function will be less dependent on getting the order of types exactly right, allowing clients potentially to better spread/modularize addition of types in their code.
  • error/sanity checking: illegal to add a conversion from a subtype to a supertype.
  • better implementation of type conversions, reduction in redundancy in conversion: a conversion from a supertype would work on all its subtypes as well, and a conversion to a subtype would convert to all supertypes as well. At the moment, if A is a subtype of B and C is a subtype of D, you might have to define all four conversions from either A or B to C or D as appropriate; with subtyping, depending on the desired behavior, this might well reduce to two conversions or even just one (from B to C).
@josdejong
Copy link
Owner

Thanks, good to have a placeholder.

For reference: #128 contains the first discussion on this.

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

No branches or pull requests

2 participants