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

Nominal type statements #30

Open
matthew-healy opened this issue Nov 20, 2023 · 0 comments
Open

Nominal type statements #30

matthew-healy opened this issue Nov 20, 2023 · 0 comments

Comments

@matthew-healy
Copy link
Owner

matthew-healy commented Nov 20, 2023

It should be trivial to create a nominal type from another type.

E.g.

type Year wraps Num

In this case this would be fine:

def before |y: Year| y < 2023

let y: Year = 1991 in
before y -- true

This would not be fine:

def before |y: Year| y < 2023

let y = 1991 in
before y -- type mismatch, ideally with a hint about requiring an explicit annotation

And equally:

def add |x: Num, y: Num| y < 2023

let y: Year = 1991 in
add 4 y -- type mismatch, with a hint about requiring an explicit annotation

(Note: the type X wraps Y syntax is bad and should be improved, but type X = Y looks like an alias rather than a newtype).

(Also note: overloading ascryption for this might be a bad idea.)

@matthew-healy matthew-healy changed the title Nominal types Nominal type statements Nov 20, 2023
@matthew-healy matthew-healy moved this to Todo in uplp Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant