Maintainer | bastiaan.heeren@ou.nl |
---|---|
Stability | provisional |
Portability | portable (depends on ghc) |
Safe Haskell | None |
Language | Haskell2010 |
Domain.Algebra.Group
Description
Synopsis
- class Semigroup a => Monoid a where
- (<>) :: Semigroup a => a -> a -> a
- class Monoid a => Group a where
- (<>-) :: Group a => a -> a -> a
- class Monoid a => MonoidZero a where
- mzero :: a
- data WithZero a
- fromWithZero :: WithZero a -> Maybe a
- class CoMonoid a where
- class CoMonoid a => CoGroup a where
- isInverse :: a -> Maybe a
- isAppendInv :: a -> Maybe (a, a)
- class CoMonoid a => CoMonoidZero a where
- isMonoidZero :: a -> Bool
- associativeList :: CoMonoid a => a -> [a]
Monoids
class Semigroup a => Monoid a where #
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following laws:
x
<>
mempty
= xmempty
<>
x = xx
(<>
(y<>
z) = (x<>
y)<>
zSemigroup
law)mconcat
=foldr
'(<>)'mempty
The method names refer to the monoid of lists under concatenation, but there are many other instances.
Some types can be viewed as a monoid in more than one way,
e.g. both addition and multiplication on numbers.
In such cases we often define newtype
s and make those instances
of Monoid
, e.g. Sum
and Product
.
NOTE: Semigroup
is a superclass of Monoid
since base-4.11.0.0.
Minimal complete definition
Methods
Identity of mappend
An associative operation
NOTE: This method is redundant and has the default
implementation
since base-4.11.0.0.mappend
= '(<>)'
Fold a list using the monoid.
For most types, the default definition for mconcat
will be
used, but the function is included in the class definition so
that an optimized version can be provided for specific types.
Instances
Groups
class Monoid a => Group a where Source #
Minimal complete definition: inverse or appendInverse
Minimal complete definition
Nothing
Instances
Field a => Group (Multiplicative a) Source # | |
Defined in Domain.Algebra.Field Methods inverse :: Multiplicative a -> Multiplicative a Source # appendInv :: Multiplicative a -> Multiplicative a -> Multiplicative a Source # | |
Ring a => Group (Additive a) Source # | |
(CoGroup a, Group a) => Group (SmartGroup a) Source # | |
Defined in Domain.Algebra.SmartGroup Methods inverse :: SmartGroup a -> SmartGroup a Source # appendInv :: SmartGroup a -> SmartGroup a -> SmartGroup a Source # |
Monoids with a zero element
class Monoid a => MonoidZero a where Source #
Instances
Monoid a => MonoidZero (WithZero a) Source # | |
Defined in Domain.Algebra.Group | |
SemiRing a => MonoidZero (Multiplicative a) Source # | |
Defined in Domain.Algebra.Field Methods mzero :: Multiplicative a Source # | |
Boolean a => MonoidZero (Or a) Source # | |
Defined in Domain.Algebra.Boolean | |
Boolean a => MonoidZero (And a) Source # | |
Defined in Domain.Algebra.Boolean | |
(MonoidZero a, CoGroup a, Group a) => MonoidZero (SmartGroup a) Source # | |
Defined in Domain.Algebra.SmartGroup Methods mzero :: SmartGroup a Source # | |
(MonoidZero a, CoMonoidZero a) => MonoidZero (SmartZero a) Source # | |
Defined in Domain.Algebra.SmartGroup | |
(MonoidZero a, CoMonoid a) => MonoidZero (Smart a) Source # | |
Defined in Domain.Algebra.SmartGroup | |
Ord a => MonoidZero (OrSet a) Source # | |
Defined in Domain.Math.Data.OrList | |
MonoidZero (OrList a) Source # | |
Defined in Domain.Math.Data.OrList |
Instances
fromWithZero :: WithZero a -> Maybe a Source #
CoMonoid, CoGroup, and CoMonoidZero (for matching)
class CoMonoid a where Source #
Instances
CoMonoid [a] Source # | |
CoMonoid (Set a) Source # | |
CoMonoid a => CoMonoid (WithZero a) Source # | |
CoSemiRing a => CoMonoid (Multiplicative a) Source # | |
Defined in Domain.Algebra.Field Methods isEmpty :: Multiplicative a -> Bool Source # isAppend :: Multiplicative a -> Maybe (Multiplicative a, Multiplicative a) Source # | |
CoSemiRing a => CoMonoid (Additive a) Source # | |
CoBoolean a => CoMonoid (Or a) Source # | |
CoBoolean a => CoMonoid (And a) Source # | |
CoMonoid a => CoMonoid (SmartGroup a) Source # | |
Defined in Domain.Algebra.SmartGroup Methods isEmpty :: SmartGroup a -> Bool Source # isAppend :: SmartGroup a -> Maybe (SmartGroup a, SmartGroup a) Source # | |
CoMonoid a => CoMonoid (SmartZero a) Source # | |
CoMonoid a => CoMonoid (Smart a) Source # | |
CoMonoid (OrSet a) Source # | |
CoMonoid (OrList a) Source # | |
class CoMonoid a => CoGroup a where Source #
Minimal complete definition
Instances
CoField a => CoGroup (Multiplicative a) Source # | |
Defined in Domain.Algebra.Field Methods isInverse :: Multiplicative a -> Maybe (Multiplicative a) Source # isAppendInv :: Multiplicative a -> Maybe (Multiplicative a, Multiplicative a) Source # | |
CoRing a => CoGroup (Additive a) Source # | |
CoGroup a => CoGroup (SmartGroup a) Source # | |
Defined in Domain.Algebra.SmartGroup Methods isInverse :: SmartGroup a -> Maybe (SmartGroup a) Source # isAppendInv :: SmartGroup a -> Maybe (SmartGroup a, SmartGroup a) Source # |
class CoMonoid a => CoMonoidZero a where Source #
Methods
isMonoidZero :: a -> Bool Source #
Instances
associativeList :: CoMonoid a => a -> [a] Source #