blamario / monoid-subclasses

Subclasses of Monoid with a solid theoretical foundation and practical purposes
BSD 3-Clause "New" or "Revised" License
33 stars 9 forks source link

monoid-subclasses

Subclasses of Semigroup and Monoid with a solid theoretical foundation and practical purposes

The monoid-subclasses package has been released on Hackage. The package defines several classes that are richer than semigroups and monoids but less demanding than groups:

That's the theoretical point of view. From the practical point of view, the main purpose of the monoid-subclasses package is similar to that of ListLike - to provide unifying abstractions for various monoidal data types in Haskell, primarily String, ByteString, and Text. All three types are already instances of the Monoid class. While that abstraction is useful for building sequences of data, it doesn't help with deconstructing them.

That being said, there are two major differences in the goals of ListLike and monoid-subclasses:

The incremental-parser package can serve as a compact example of a parser library that can be applied to different input types thanks to monoid-subclasses. There is also picoparsec, a fork of attoparsec, and the heavy-duty grammatical-parsers library.

A more thorough description of the library design can be found in the Haskell Symposium 2013 paper Adding Structure to Monoids