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

Type Aliases #1349

Closed
mariari opened this issue Jun 30, 2022 · 3 comments · Fixed by #1404
Closed

Type Aliases #1349

mariari opened this issue Jun 30, 2022 · 3 comments · Fixed by #1404
Assignees
Labels
Milestone

Comments

@mariari
Copy link
Member

mariari commented Jun 30, 2022

A lot of MiniJuvix syntax allows Unicode and non Unicode versions, for example

xy-point : ℕ -> ℕ -> Point;
xy-point x y := from-complex (complex x y);

xy-point' : ℕ → ℕ → Point;
xy-point' x y ≔ from-complex (complex x y);

which is nice, as the user may not be writing from an environment which can easily input Unicode symbols.

however, the same could not be said of types. So in the stdlib there is , but no Nat.

It would be nice if there could exist such type aliases.

Since types are defined with inductive, which is a very specific term, I propose another keyword

alias Nat = 

However, this has the downside of needing more keywords, and I suspect if there are sugar for records we'd end up with inductive, alias, and record all being keywords, potentially breaking user code when they are added in.

Ideally we could just do all these with a generic word like type instead.

@janmasrovira
Copy link
Collaborator

In the near future we will try to extend the current type system
to include simple functions that return a type. What I mean by simple is yet to be precisely defined. However, a function such as the following will certainly be accepted:

Nat : Type;
Nat ≔ ℕ;

This will be enough to have type aliases. However, the unicode problem does not end here. We will (probably) still have constructors that use unicode characters, such as .
Of course, one can define a synonym for it thus:

cons : {A : Type} → A → List A → List A;
cons = (∷);

however cons is a function but not a constructor so it can't be used in patterns. For that, we would need pattern synonyms, which we may support in the future but not soon.

That being said, I think (and we will discuss it more thoroughly when extending the stdlib) that we are commited to using unicode extensively and thus we will develop with the assumption that the user should be able and comfortable with unicode.

@mariari
Copy link
Member Author

mariari commented Jul 1, 2022

In the near future we will try to extend the current type system to include simple functions that return a type. What I mean by simple is yet to be precisely defined. However, a function such as the following will certainly be accepted:

Nat : Type;
Nat ≔ ℕ;

This will be enough to have type aliases. However, the unicode problem does not end here. We will (probably) still have constructors that use unicode characters, such as . Of course, one can define a synonym for it thus:

cons : {A : Type} → A → List A → List A;
cons = (∷);

however cons is a function but not a constructor so it can't be used in patterns. For that, we would need pattern synonyms, which we may support in the future but not soon.

That being said, I think (and we will discuss it more thoroughly when extending the stdlib) that we are commited to using unicode extensively and thus we will develop with the assumption that the user should be able and comfortable with unicode.

I would worry that the syntax of

Nat : Type;
Nat  ;

would give off the wrong impression. Namely that types are values, and thus functions can be used in the same way as the rest of the language in which it can't.

@janmasrovira
Copy link
Collaborator

janmasrovira commented Jul 4, 2022

We think that going with the long-term syntax, even though we will not support full dependent types soon, is the best option.

@cwgoes cwgoes transferred this issue from another repository Jul 13, 2022
@jonaprieto jonaprieto added this to the 0.2.2 milestone Jul 14, 2022
@janmasrovira janmasrovira linked a pull request Jul 20, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants