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

Add PartialMonoid typeclass #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pniedzielski
Copy link

It is sometimes useful to consider partial semigroups that also have an identity element, say pmempty. Many, but not all, partial semigroups that have instances in this library are also partial monoids, with some identity element. This patch introduces a typeclass, PartialMonoid, that represents such types. This typeclass is meant to directly mirror the standard Monoid typeclass, prepending pm to each function in the standard typeclass and changing their types to represent partiality. The only deviation here is removing pmappend from the typeclass, since this is necessarily an alias for <>? specialized to monoids; unlike with the standard mappend, by moving this out of the typeclass, we avoid any possibility of unlawful instances where pmappend ≢ (<>?).

This patch tags each addition with a @since 0.7.0.0 Haddock annotation, on the assumption that these changes will be included in a new release of the library with that version.

Fixes #13.

It is sometimes useful to consider partial semigroups that also have
an identity element, say `pmempty`.  Many, but not all, partial
semigroups that have instances in this library are also partial
monoids, with some identity element.  This patch introduces a
typeclass, `PartialMonoid`, that represents such types.  This
typeclass is meant to directly mirror the standard `Monoid` typeclass,
prepending `pm` to each function in the standard typeclass and
changing their types to represent partiality.  The only deviation here
is removing `pmappend` from the typeclass, since this is necessarily
an alias for `<>?` specialized to monoids; unlike with the standard
`mappend`, by moving this out of the typeclass, we avoid any
possibility of unlawful instances where `pmappend ≢ (<>?)`.

This patch tags each addition with a `@since 0.7.0.0` Haddock
annotation, on the assumption that these changes will be included in a
new release of the library with that version.
@pniedzielski
Copy link
Author

Hi @chris-martin, if you have a chance, could you review this PR?

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.

Add PartialMonoid typeclass
1 participant