ideas-1.2: Feedback services for intelligent tutoring systems

Portability portable (depends on ghc) provisional bastiaan.heeren@ou.nl None

Ideas.Common.Algebra.Group

Description

Synopsis

# Monoids

class Monoid a where

The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following laws:

• mappend mempty x = x
• mappend x mempty = x
• mappend x (mappend y z) = mappend (mappend x y) z
• mconcat = foldr mappend mempty

The method names refer to the monoid of lists under concatenation, but there are many other instances.

Minimal complete definition: mempty and mappend.

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 newtypes and make those instances of Monoid, e.g. Sum and Product.

Methods

mempty :: a

Identity of mappend

mappend :: a -> a -> a

An associative operation

mconcat :: [a] -> a

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

 Monoid Ordering Monoid () Monoid All Monoid Any Monoid ByteString Monoid ByteString Monoid IntSet Monoid XMLBuilder Monoid Rating Monoid Status Monoid Message Monoid Result Monoid TestSuite Monoid Id Monoid Environment Monoid Substitution Monoid Location Monoid Text Monoid Script Monoid DomainReasoner Monoid [a] Monoid a => Monoid (Dual a) Monoid (Endo a) Num a => Monoid (Sum a) Num a => Monoid (Product a) Monoid (First a) Monoid (Last a) Monoid a => Monoid (Maybe a) Lift a semigroup into Maybe forming a Monoid according to http://en.wikipedia.org/wiki/Monoid: "Any semigroup S may be turned into a monoid simply by adjoining an element e not in S and defining e*e = e and e*s = s = s*e for all s ∈ S." Since there is no "Semigroup" typeclass providing just mappend, we use Monoid instead. Monoid (Seq a) Monoid (IntMap a) Ord a => Monoid (Set a) Monoid (ArbGen a) Monoid a => Monoid (WithZero a) SemiRing a => Monoid (Multiplicative a) SemiRing a => Monoid (Additive a) Monoid (Recognizer a) Monoid (Option a) Boolean a => Monoid (Or a) Boolean a => Monoid (And a) (CoGroup a, Group a) => Monoid (SmartGroup a) (CoMonoidZero a, MonoidZero a) => Monoid (SmartZero a) (CoMonoid a, Monoid a) => Monoid (Smart a) Monoid b => Monoid (a -> b) (Monoid a, Monoid b) => Monoid (a, b) Ord k => Monoid (Map k v) Monoid (Trans a b) (Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) Monoid b => Monoid (EncoderState st a b) (Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) (Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e)

(<>) :: Monoid m => m -> m -> m

An infix synonym for mappend.

# Groups

class Monoid a => Group a whereSource

Minimal complete definition: inverse or appendInverse

Methods

inverse :: a -> aSource

appendInv :: a -> a -> aSource

Instances

 Field a => Group (Multiplicative a) Ring a => Group (Additive a) (CoGroup a, Group a) => Group (SmartGroup a)

(<>-) :: Group a => a -> a -> aSource

# Monoids with a zero element

class Monoid a => MonoidZero a whereSource

Methods

mzero :: aSource

Instances

 Monoid a => MonoidZero (WithZero a) SemiRing a => MonoidZero (Multiplicative a) Boolean a => MonoidZero (Or a) Boolean a => MonoidZero (And a) (CoGroup a, MonoidZero a, Group a) => MonoidZero (SmartGroup a) (CoMonoidZero a, MonoidZero a) => MonoidZero (SmartZero a) (CoMonoid a, MonoidZero a) => MonoidZero (Smart a)

data WithZero a Source

Instances

 Functor WithZero Applicative WithZero Foldable WithZero Traversable WithZero Eq a => Eq (WithZero a) Ord a => Ord (WithZero a) Monoid a => Monoid (WithZero a) CoMonoid a => CoMonoidZero (WithZero a) CoMonoid a => CoMonoid (WithZero a) Monoid a => MonoidZero (WithZero a)

# CoMonoid, CoGroup, and CoMonoidZero (for matching)

class CoMonoid a whereSource

Methods

isEmpty :: a -> BoolSource

isAppend :: a -> Maybe (a, a)Source

Instances

 CoMonoid [a] CoMonoid (Set a) CoMonoid a => CoMonoid (WithZero a) CoSemiRing a => CoMonoid (Multiplicative a) CoSemiRing a => CoMonoid (Additive a) CoBoolean a => CoMonoid (Or a) CoBoolean a => CoMonoid (And a) CoMonoid a => CoMonoid (SmartGroup a) CoMonoid a => CoMonoid (SmartZero a) CoMonoid a => CoMonoid (Smart a)

class CoMonoid a => CoGroup a whereSource

Methods

isInverse :: a -> Maybe aSource

isAppendInv :: a -> Maybe (a, a)Source

Instances

 CoField a => CoGroup (Multiplicative a) CoRing a => CoGroup (Additive a) CoGroup a => CoGroup (SmartGroup a)

class CoMonoid a => CoMonoidZero a whereSource

Methods

isMonoidZero :: a -> BoolSource

Instances

 CoMonoid a => CoMonoidZero (WithZero a) CoSemiRing a => CoMonoidZero (Multiplicative a) CoBoolean a => CoMonoidZero (Or a) CoBoolean a => CoMonoidZero (And a) CoMonoidZero a => CoMonoidZero (SmartGroup a) CoMonoidZero a => CoMonoidZero (SmartZero a) CoMonoidZero a => CoMonoidZero (Smart a)