-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Algebraic structures
--
-- Algebraic structures
@package alg
@version 0.1.1.0
module Algebra
-- | The class of semigroups (types with an associative binary operation).
class Semigroup a
-- | An associative operation.
--
--
-- (a <> b) <> c = a <> (b <> c)
--
--
-- If a is also a Monoid we further require
--
--
-- (<>) = mappend
--
(<>) :: Semigroup a => a -> a -> a
-- | Reduce a non-empty list with <>
--
-- The default definition should be sufficient, but this can be
-- overridden for efficiency.
sconcat :: Semigroup a => NonEmpty a -> a
-- | Repeat a value n times.
--
-- Given that this works on a Semigroup it is allowed to fail if
-- you request 0 or fewer repetitions, and the default definition will do
-- so.
--
-- By making this a member of the class, idempotent semigroups and
-- monoids can upgrade this to execute in O(1) by picking
-- stimes = stimesIdempotent or stimes =
-- stimesIdempotentMonoid respectively.
stimes :: (Semigroup a, Integral b) => b -> a -> a
-- | The class of monoids (types with an associative binary operation that
-- has an identity). Instances should satisfy the following laws:
--
--
--
-- 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
-- newtypes and make those instances of Monoid, e.g.
-- Sum and Product.
class Monoid a
-- | Identity of mappend
mempty :: Monoid a => a
class Monoid a => Group a
invert :: Group a => a -> a
(+) :: Semigroup (Sum a) => a -> a -> a
(-) :: (Semigroup (Sum a), Group (Sum a)) => a -> a -> a
(*) :: Semigroup (Product a) => a -> a -> a
(/) :: (Semigroup (Product a), Group (Product a)) => a -> a -> a
instance Algebra.Group ()
instance (Algebra.Group a, Algebra.Group b) => Algebra.Group (a, b)
instance (Algebra.Group a, Algebra.Group b, Algebra.Group c) => Algebra.Group (a, b, c)
instance (Algebra.Group a, Algebra.Group b, Algebra.Group c, Algebra.Group d) => Algebra.Group (a, b, c, d)
instance (Algebra.Group a, Algebra.Group b, Algebra.Group c, Algebra.Group d, Algebra.Group e) => Algebra.Group (a, b, c, d, e)
instance Algebra.Group a => Algebra.Group (Data.Functor.Identity.Identity a)
instance Algebra.Group a => Algebra.Group (Data.Monoid.Dual a)
instance forall k (a :: k). Algebra.Group (Data.Proxy.Proxy a)
instance forall k a (b :: k). Algebra.Group a => Algebra.Group (Data.Functor.Const.Const a b)
instance Algebra.Group b => Algebra.Group (a -> b)
instance Algebra.Group a => Algebra.Group (GHC.Types.IO a)
instance Algebra.Group (Data.Monoid.Sum GHC.Integer.Type.Integer)