-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Adding type aliases #704
Adding type aliases #704
Conversation
docs/src/adr/002adr-types.md
Outdated
typeVar ::= <a single letter from [a-z]> | ||
|
||
alias ::= <an identifier that matches [a-zA-Z_][a-zA-Z0-9_]* and | ||
is neither typeConst, nor typeVar > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these patterns overlap, does this mean "is neither a (predefined) typeConst or typeVar"? If so, I'm not clear how the typeVar case applies, since typeVar's aren't defined previously, but just identified syntactically. Should you perhaps constrain aliases to being [A-Z_][a-zA-Z0-9_]*
so there's no possibility of confusing a type variable for a type alias?
* `Proc` and `Faulty` are sets of the same type. | ||
Their type is `Set(PID)`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does PID come from? What does it mean?
docs/src/adr/002adr-types.md
Outdated
We extend the type grammar of `T` with one more rule that introduces a type | ||
alias: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We extend the type grammar of `T` with one more rule that introduces a type | |
alias: | |
We extend the type grammar of `T` with one more rule that introduces type | |
aliases: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This intro to the section doesn't make sense to me, because the type alias is specified in the grammar to begin with, not added as an extensions here (the way the current document is written). Perhaps just say "kthe grammer of T
includes a rule" rather than "we extend"?
@@ -1,44 +0,0 @@ | |||
package at.forsyte.apalache.tla.typecheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change related to the feature added in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Caching is not consistent with type aliases. If we want to cache parsing results, we have to take the aliases into account. That seems to be too difficult. There is no good use case for caching anyways.
Co-authored-by: Shon Feder <shon@informal.systems>
Co-authored-by: Shon Feder <shon@informal.systems>
The first solution to aliases was not working well:
Here is a new solution. We just let the user redefine a constant type as an alias: \* @typeAlias: ENTRY = Str;
\* @type: Int -> ENTRY; I find this approach much more elegant. It also gives us another use for the type constants. |
@shonfeder, if you have time, please have a look at it. |
Per popular request this PR adds type aliases of the form:
This closes #703.
make fmt-fix
(or had formatting run automatically on all files edited)