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.
This PR introduces
Prairie.Semigroup
, allowing you toappendRecord :: (Record rec, FieldDict Semigroup rec) => rec -> rec -> rec
. We also getPrairie.Monoid
, giving youemptyRecord :: (Record rec, FieldDict Monoid rec) => rec
. These are pretty self-explanatory.appendRecord
is implemented withzipWithRecord :: (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 forDerivingVia
which lets you deriveMonoid
andSemigroup
instances using the behavior ofappendRecord
andemptyRecord
.Before submitting your PR, check that you've:
@since
declarations to the Haddock.stylish-haskell
and otherwise adhered to the style guide.After submitting your PR: