-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Implement new builder syntax alongside old one #6883
Conversation
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.
Good job! I left a few comments on potential improvements and some nitpicking.
I'm really looking forward to this 😄
It'd be nice to add some "end-to-end" tests (maybe in cli?) that actually ran some record builders |
I've added a few tests in the |
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.
Nice! Thanks for all the updates. I left some optional suggestions.
|
||
// CalledVia::RecordBuilder => { | ||
// alloc.concat([ | ||
// alloc.note(""), | ||
// alloc.reflow("Record builders need a mapper function before the "), | ||
// alloc.keyword("<-"), | ||
// alloc.reflow(" to combine fields together with.") | ||
// ]) | ||
// } | ||
// _ => { | ||
// alloc.reflow("Are there any missing commas? Or missing parentheses?") |
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 seems like a leftover comment
Note: Record builders need a mapper function before the `<-` to combine | ||
fields together with. |
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.
I'd simplify this a bit. Using the word "mapper" might confuse people if they think it's a common term and they try to google it.
Note: Record builders need a mapper function before the `<-` to combine | |
fields together with. | |
Note: Record builders need a function before the `<-` to combine fields. |
Once we update the tutorial, I think we should include a link to the record builders section here.
map_with_arena( | ||
either( | ||
byte(b'&', ERecord::Ampersand), | ||
two_bytes(b'<', b'-', ERecord::Arrow), | ||
), | ||
|_arena, output| match output { | ||
Either::First(()) => RecordHelpPrefix::Update, | ||
Either::Second(()) => RecordHelpPrefix::Mapper, | ||
} | ||
) |
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.
nit: Not using arena
, you could just use map
here.
This PR implements the new style of the record builder syntax (using map2 functions) as described by @agu-z in this Zulip thread.
_
to ignore record builder fields, that can be added after by updating thedesugar.rs
logic WRT handling malformed field names.Here's an example of the syntax that works with this branch:
Which prints