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 #13

Open
pniedzielski opened this issue Dec 24, 2023 · 2 comments · May be fixed by #14
Open

Add PartialMonoid typeclass #13

pniedzielski opened this issue Dec 24, 2023 · 2 comments · May be fixed by #14

Comments

@pniedzielski
Copy link

A useful edition to this package would be the addition of a PartialMonoid typeclass that extends PartialSemigroup with identity:

class PartialSemigroup α ⇒ PartialMonoid α where
    -- | Identity of '<>?'.
    pempty ∷ α
    pempty = fromJust $ pmconcat []

    -- | Reduce a list with '<>?'.
    pmconcat ∷ [α] → Maybe α
    pmconcat = foldM (<>?) pempty

    {-# MINIMAL (pempty) | pmconcat #-}

I'm working on a package for working with Minimalist Grammars in Haskell, and I have found that both PartialSemigroup and a PartialMonoid class (taken as above from my code) simplify constructing parsers greatly.

I would be willing to take on this issue.

@chris-martin
Copy link
Member

That sounds cool! I don't have a ton of free time for this but if you'd submit a PR I'd be glad to incorporate it. I wouldn't mind adding you as a package maintainer either, if you're up for that.

@pniedzielski
Copy link
Author

Wonderful, I'm planning on making a PR soon with this addition. I would certainly be okay being a package maintainer as well, if that makes things easier on your end.

@pniedzielski pniedzielski linked a pull request Feb 14, 2024 that will close this issue
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 a pull request may close this issue.

2 participants