The monoid-subclasses package

[Tags:bsd3, library, test]

A hierarchy of subclasses of Monoid together with their instances for all data structures from base, containers, and text packages.


[Skip to Readme]

Properties

Versions 0.1, 0.1.1, 0.1.2, 0.2, 0.3, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.4.1, 0.3.5, 0.3.6, 0.3.6.1, 0.3.6.2, 0.4, 0.4.0.1, 0.4.0.2, 0.4.0.3, 0.4.0.4, 0.4.1, 0.4.1.1, 0.4.1.2, 0.4.2, 0.4.2.1, 0.4.3
Dependencies base (>=4.5 && <5), bytestring (>=0.9 && <1.0), containers (>=0.5.7.0 && <0.6), primes (==0.2.*), text (>=0.11 && <1.3), vector (>=0.9 && <0.12) [details]
License BSD3
Copyright (c) 2013-2016 Mario Blazevic
Author Mario Blazevic
Maintainer Mario Blazevic <blamario@yahoo.com>
Stability Unknown
Category Data, Algebra, Text
Home page https://github.com/blamario/monoid-subclasses/
Bug tracker https://github.com/blamario/monoid-subclasses/issues
Source repository head: git clone https://github.com/blamario/monoid-subclasses
Uploaded Tue Sep 27 03:51:00 UTC 2016 by MarioBlazevic
Distributions Arch:0.4.3, Debian:0.4.1.2, LTSHaskell:0.4.2.1, NixOS:0.4.3, Stackage:0.4.3, Tumbleweed:0.4.2.1
Downloads 4309 total (114 in the last 30 days)
Votes
1 []
Status Docs available [build log]
Last success reported on 2016-09-27 [all 1 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for monoid-subclasses

Readme for monoid-subclasses-0.4.3

monoid-subclasses

Subclasses of 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 monoids but less demanding than groups:

  • ReductiveMonoid provides the operator </> which acts as a partial inverse of the <> operator, i.e., Monoid.mappend.

  • CancellativeMonoid is a subclass of ReductiveMonoid that provides additional guarantees about the </> operation result:

    (a <> b) </> a == Just b
    (a <> b) </> b == Just a
    

    Every group (<em>i.e.</em>, every Monoid a with the operation inverse :: a -> a) is a CancellativeMonoid where a </> b = Just (a <> inverse b) but not every CancellativeMonoid is a group.

  • GCDMonoid is a subclass of ReductiveMonoid that provides the gcd operation for getting the greatest common denominator for two given monoid values.

  • MonoidNull class provides the Boolean null operation that checks if the argument monoid is mempty.

  • FactorialMonoid class represents monoids that can be split up into irreducible factors.

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:

  • ListLike strives to reproduce the standard Data.List interface, whereas monoid-subclasses builds from deeper theoretical foundations; and
  • The monoid-subclasses implementation uses standard Haskell 2010, with the exception of two minor extensions which can be worked around if necessary.

The incremental-parser package provides one example of use of monoid-subclasses. Another example is picoparsec, a fork of attoparsec.

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