-
Notifications
You must be signed in to change notification settings - Fork 51
Implement type aliases #72
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
Conversation
|
I haven’t had the chance to look over this in detail yet—I definitely will soon—but my immediate comment is whether or not we want to use a name other than (I’ve also been sort of reconsidering naming definition forms things like |
|
Thats a really good point. At the very least, a more racket-y name like If you have a particular name in mind I think we should use it, and that could help get the ball rolling for renaming other forms. |
|
|
|
I would lean toward one of these sets of names:
(1) is closest to Haskell, and closest to how Hackett looks currently. It's what I'm leaning toward under the assumption that we don't want to change the existing Hackett forms too much. (3) is closest to Racket's convention. (2) is in between, and could look reasonable next to I don't think we need the word "alias" in the name. The documentation can clarify that. Both Haskell's and Racket's forms don't normally include "alias". |
Personally, I think we do. I’ve experienced firsthand the amount of confusion the awful |
|
|
||
| @(hackett-examples | ||
| #:eval alias-examples-eval | ||
| ;#:no-preserve-source-locations |
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.
For some reason if I uncomment this line, I get an error on line 342. Can you reproduce this?
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.
Not preserving source locations currently has the unfortunate side-effect of dropping syntax properties, so your use of { curly braces } will be lost. This is a bug in scribble/example that I haven’t bothered fixing.
| @(hackett-examples | ||
| #:eval alias-examples-eval | ||
| ;#:no-preserve-source-locations | ||
| (type (Predicate T) {T t:-> t:Bool}) |
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 is (morally) Haskell; type variables should be lowercase by convention.
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.
That's right. Fixed!
|
Should we rename it from |
|
I think I’m okay with |
|
Almost. The last think is whether infix should work. Something like this currently fails: (type (~> t u) #:fixity right (-> t (Maybe u)))
(defn pure : (∀ [t] {t ~> t}) [[x] (Just x)])
;. ~>: expected 2 argument(s) to type alias in: ~>While writing it as |
|
Although if we needed to we could specify in the Docs that only prefix syntax is supported when applying type aliases to arguments. |
|
Ah, yes—the issue here is essentially that infix notation is controlled by I think the fix is to change the |
|
It sounds like that will be a more major change. Should we keep aliases without infix support for now, and think about reworking |
|
I don’t think it should be too difficult, but I agree that it’s outside the immediate scope of this particular feature. I’m happy to deal with the infix issue myself when I get a moment to look at it, if you’d prefer. |
|
Okay. Should I remove the |
|
I’d leave it as it is for now. I’d consider the lack of infix support a bug in Hackett’s infix implementation a bug more than anything else; I’ll plan to fix it quickly. |
|
I've changed the docs, adding a margin note to say that they can only be used with prefix notation. |
|
I would feel comfortable with this being merged now. |
Adds a
typeform for type aliases.(type name-id maybe-fixity type-expr) (type (name-id param-id ...) type-expr)type