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

Semigroups, Monoids, Zips, and AsRecord #13

Merged
merged 6 commits into from
Apr 11, 2024

Conversation

parsonsmatt
Copy link
Owner

@parsonsmatt parsonsmatt commented Apr 11, 2024

This PR introduces Prairie.Semigroup, allowing you to appendRecord :: (Record rec, FieldDict Semigroup rec) => rec -> rec -> rec. We also get Prairie.Monoid, giving you emptyRecord :: (Record rec, FieldDict Monoid rec) => rec. These are pretty self-explanatory.

appendRecord is implemented with zipWithRecord :: (Record rec) => (forall ty. ty -> ty -> Field rec ty -> ty) -> rec -> rec -> rec, also introduced here. This allows you to combine two records with a function specifying how to combine the values.

Finally, we provide AsRecord, a newtype for DerivingVia which lets you derive Monoid and Semigroup instances using the behavior of appendRecord and emptyRecord.

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR.
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts).

Copy link

@evanrelf evanrelf left a comment

Choose a reason for hiding this comment

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

Sick

@parsonsmatt parsonsmatt merged commit c4fd756 into master Apr 11, 2024
7 checks passed
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.

None yet

2 participants