-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add short syntax for dependent functor types #12828
Conversation
This PR
In short, it looks like an excellent change, I'm wholly in favour! |
I don't personally see functor types enough to perceive a real need for this syntactic sugar, but I see no harm with it either, and it is consistent with the previous shortcut syntaxes we introduced as @yallop recalled. I am tempted to vote in favor, unless someone comes with a counter-argument. |
3a64baf
to
9249b3c
Compare
I've rebased to resolve conflicts, and credited @nojb as reviewer. |
This is a big change in terms of modified outputs, but I agree this looks nicer. The |
9249b3c
to
331d663
Compare
331d663
to
2869c4a
Compare
I've fixed the conflict, incorporated @gasche's proposed change (which I'd somehow completely missed; sorry!) and credited him as a reviewer. |
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.
LGTM
Brief summary
This PR adds a concise variant of functor type syntax. In brief, it allows (but does not require) the keyword
functor
to be omitted in functor types (but not in functor terms).In other words, the current functor syntax looks like this:
and this PR extends the syntax to also allow writing this:
The new syntax is commonly used in dependently-typed languages such as Agda and Idris.
Previous episodes
The PR is the latest installment in an occasional series of functor type syntax simplifications. Previous episodes:
Simplify functor sig types #16 (OCaml 4.02.0) added shorter syntax for functor signatures, allowing
-> functor
to be omitted for type parameters after the first:Before:
After:
Short functor type syntax #42 (OCaml 4.03.0) added shorter syntax for non-dependent functor parameters, allowing parameter names to be omitted
:
Before:
After:
Add short syntax for generative functor types: () -> ... #11694 (OCaml 5.1.0) added similarly short syntax for generative functor types:
Before:
After:
Motivation
Functor types occur occasionally in programs, but appear quite often in error messages and top-level printing, where the full syntax can make them rather difficult to read. Here is a fairly typical example from the test suite:
After this PR the message is shorter:
Omitting
functor
makes the error message significantly shorter (15 lines rather than 23) because it allows the parameter types to fit on a single line.