Hoogle Search

Within LTS Haskell 16.8 (ghc-8.8.3)

  1. monoid :: forall a . (Monoid a, Show a, Arbitrary a, EqProp a) => a -> TestBatch

    checkers Test.QuickCheck.Classes

    Properties to check that the Monoid a satisfies the monoid properties. The argument value is ignored and is present only for its type.

  2. class Semigroup a => Monoid a

    base Prelude

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

    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. NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.

  3. module Data.Monoid

    A type a is a Monoid if it provides an associative function (<>) that lets you combine any two values of type a into one, and a neutral element (mempty) such that

    a <> mempty == mempty <> a == a
    
    A Monoid is a Semigroup with the added requirement of a neutral element. Thus any Monoid is a Semigroup, but not the other way around.

    Examples

    The Sum monoid is defined by the numerical addition operator and `0` as neutral element:
    >>> mempty :: Sum Int
    Sum 0
    
    >>> Sum 1 <> Sum 2 <> Sum 3 <> Sum 4 :: Sum Int
    Sum {getSum = 10}
    
    We can combine multiple values in a list into a single value using the mconcat function. Note that we have to specify the type here since Int is a monoid under several different operations:
    >>> mconcat [1,2,3,4] :: Sum Int
    Sum {getSum = 10}
    
    >>> mconcat [] :: Sum Int
    Sum {getSum = 0}
    
    Another valid monoid instance of Int is Product It is defined by multiplication and `1` as neutral element:
    >>> Product 1 <> Product 2 <> Product 3 <> Product 4 :: Product Int
    Product {getProduct = 24}
    
    >>> mconcat [1,2,3,4] :: Product Int
    Product {getProduct = 24}
    
    >>> mconcat [] :: Product Int
    Product {getProduct = 1}
    

  4. class Semigroup a => Monoid a

    base Data.Monoid

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

    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. NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.

  5. class Semigroup a => Monoid a

    base GHC.Base

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

    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. NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.

  6. class Semigroup a => Monoid a

    hspec Test.Hspec.Discover

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

    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. NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.

  7. class Semigroup a => Monoid a

    base-compat Data.Monoid.Compat

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

    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. NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.

  8. class Semigroup a => Monoid a

    hedgehog Hedgehog.Internal.Prelude

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

    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. NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.

  9. class Semigroup a => Monoid a

    validity Data.Validity

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

    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. NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.

  10. class Semigroup a => Monoid a

    Cabal Distribution.Compat.Prelude.Internal

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

    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. NOTE: Semigroup is a superclass of Monoid since base-4.11.0.0.

Page 1 of many | Next