Skip to content

Add PartialMonoid typeclass #13

@pniedzielski

Description

@pniedzielski

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions