-
Notifications
You must be signed in to change notification settings - Fork 6
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
Section syntax #1
Comments
It occurred to me that if you wanted to support NamedFieldPuns then the syntax is ambiguous in expressions. |
Hmm... Getting trickier. We'll need to research on the subject.
I'd much rather avoid a quasi-quoter-based logic. We should develop a syntax which we would not have to change in case at some point we implement a preprocessor, or hopefully implement a GHC syntax extension. |
I kind of assumed that was the goal. I thought it'd be nice to be able to postprocess the generated function (for newtypes mainly, but also for functions like Then the syntax without the backslash character would indicate a record pattern/expression, and I think would handle both RecordWildCards and NamedFieldPuns cleanly. EDIT: I guess full expressions wouldn't work that nicely, since |
Wait a second. I just realised that |
They apply to both unfortunately. In an expression |
Oh.. |
Another option would be something like Though NamedFieldPuns in an expression might cause issues in general; assuming the lenses are in scope and have the same name as the field then barring a special compiler rule for FieldOwner |
Problem
Proposal
Unquote an expression of the following form
[r| {name, age} |]
to
(Note the reordering of arguments).
Then it will be possible to use it like this:
Extras
This can be extended even further to allow to partially initialize the record. E.g.:
Credits for the initial proposal go to a Reddit user htebalaka. Thank you!
The text was updated successfully, but these errors were encountered: