Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

## Synopsis

- class Semigroup m => AbelianSemigroup m
- data FreeAbelianSemigroup a
- toNonEmpty :: FreeAbelianSemigroup a -> NonEmpty (a, Integer)
- fromNonEmpty :: Ord a => NonEmpty (a, Integer) -> Maybe (FreeAbelianSemigroup a)

# Documentation

class Semigroup m => AbelianSemigroup m Source #

Class of commutative monoids, e.g. with additional law:
```
a <> b = b <> a
```

## Instances

data FreeAbelianSemigroup a Source #

Free abelian semigroup is isomorphic to a non empty map with keys `a`

and
values positive natural numbers.

## Instances

toNonEmpty :: FreeAbelianSemigroup a -> NonEmpty (a, Integer) Source #

fromNonEmpty :: Ord a => NonEmpty (a, Integer) -> Maybe (FreeAbelianSemigroup a) Source #

Smart constructor which creates `FreeAbelianSemigroup`

from a non empty list
of pairs `(a, n) :: (a, Integer)`

where `n > 0`

.