-
Notifications
You must be signed in to change notification settings - Fork 19
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
Refactor Protobufs code #561
Conversation
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
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.
Thanks for the attention to detail
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.
Looks better to me.
I will say that I don't personally like indenting the =>
arrow on matches to the same column. It looks nicer when reading the code, but it tends to require making changes to unrelated lines of code when adding a new match case or changing a pattern, making some diffs harder to understand and potentially creating merge conflicts. Wondering what other people think about this.
Co-authored-by: Craig Disselkoen <cdiss@amazon.com>
…-refactor Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
| [], _ => y.slotEnv | ||
| _, [] => x.slotEnv | ||
| xkvs, ykvs => Data.Map.make $ xkvs ++ ykvs | ||
| [], _ => y.slotEnv |
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.
The =>
aligned cases are so nice to look at :D
pure ignore | ||
| 1 => | ||
let x : Proto.Map String (Qualified ProtoType) ← Field.guardedParse t | ||
pureMergeFn (RecordType.mergeAttrs · x.toList) |
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.
Lots of boilerplate eliminated with pureMergFn
!
@@ -27,6 +27,8 @@ namespace Proto | |||
|
|||
def MergeFn (α : Type) : Type := (α → BParsec α) | |||
|
|||
def pureMergeFn (f : α → α) : BParsec (MergeFn α) := pure (f <$> pure ·) |
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!
Description of changes:
There are two kinds of changes in this PR.
pureMergeFn
such thatpure (pure $ f)
becomespureMergeFn f
.match
expressions.