Skip to content
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

Merged
merged 7 commits into from
Mar 17, 2025
Merged

Refactor Protobufs code #561

merged 7 commits into from
Mar 17, 2025

Conversation

shaobo-he-aws
Copy link
Contributor

@shaobo-he-aws shaobo-he-aws commented Mar 2, 2025

Description of changes:

There are two kinds of changes in this PR.

  1. Added a function pureMergeFn such that pure (pure $ f) becomes pureMergeFn f.
  2. Performed a best-effort formatting of match expressions.

Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Copy link
Contributor

@cdisselkoen cdisselkoen left a 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

Copy link
Contributor

@john-h-kastner-aws john-h-kastner-aws left a 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.

shaobo-he-aws and others added 3 commits March 3, 2025 07:52
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>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
@shaobo-he-aws shaobo-he-aws merged commit 9c10b0d into main Mar 17, 2025
6 checks passed
@shaobo-he-aws shaobo-he-aws deleted the chore/shaobo/protobuf-refactor branch March 17, 2025 20:44
| [], _ => y.slotEnv
| _, [] => x.slotEnv
| xkvs, ykvs => Data.Map.make $ xkvs ++ ykvs
| [], _ => y.slotEnv
Copy link
Contributor

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)
Copy link
Contributor

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 ·)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants