papa-base-export-0.4: Prelude with only useful functions

Papa.Base.Export.Data.Monoid

Synopsis

# Documentation

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.

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.

Minimal complete definition

Methods

mempty :: a #

Identity of mappend

mappend :: a -> a -> a #

An associative operation

Instances

 Since: 2.1 Methodsmconcat :: [Ordering] -> Ordering # Monoid () Since: 2.1 Methodsmempty :: () #mappend :: () -> () -> () #mconcat :: [()] -> () # Since: 2.1 Methodsmappend :: All -> All -> All #mconcat :: [All] -> All # Since: 2.1 Methodsmappend :: Any -> Any -> Any #mconcat :: [Any] -> Any # Monoid [a] Since: 2.1 Methodsmempty :: [a] #mappend :: [a] -> [a] -> [a] #mconcat :: [[a]] -> [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 used to be no "Semigroup" typeclass providing just mappend, we use Monoid instead.Since: 2.1 Methodsmempty :: Maybe a #mappend :: Maybe a -> Maybe a -> Maybe a #mconcat :: [Maybe a] -> Maybe a # Monoid a => Monoid (IO a) Since: 4.9.0.0 Methodsmempty :: IO a #mappend :: IO a -> IO a -> IO a #mconcat :: [IO a] -> IO a # (Ord a, Bounded a) => Monoid (Min a) Since: 4.9.0.0 Methodsmempty :: Min a #mappend :: Min a -> Min a -> Min a #mconcat :: [Min a] -> Min a # (Ord a, Bounded a) => Monoid (Max a) Since: 4.9.0.0 Methodsmempty :: Max a #mappend :: Max a -> Max a -> Max a #mconcat :: [Max a] -> Max a # Monoid m => Monoid (WrappedMonoid m) Since: 4.9.0.0 Methodsmconcat :: [WrappedMonoid m] -> WrappedMonoid m # Semigroup a => Monoid (Option a) Since: 4.9.0.0 Methodsmappend :: Option a -> Option a -> Option a #mconcat :: [Option a] -> Option a # Monoid a => Monoid (Dual a) Since: 2.1 Methodsmempty :: Dual a #mappend :: Dual a -> Dual a -> Dual a #mconcat :: [Dual a] -> Dual a # Monoid (Endo a) Since: 2.1 Methodsmempty :: Endo a #mappend :: Endo a -> Endo a -> Endo a #mconcat :: [Endo a] -> Endo a # Num a => Monoid (Sum a) Since: 2.1 Methodsmempty :: Sum a #mappend :: Sum a -> Sum a -> Sum a #mconcat :: [Sum a] -> Sum a # Num a => Monoid (Product a) Since: 2.1 Methodsmappend :: Product a -> Product a -> Product a #mconcat :: [Product a] -> Product a # Monoid (First a) Since: 2.1 Methodsmempty :: First a #mappend :: First a -> First a -> First a #mconcat :: [First a] -> First a # Monoid (Last a) Since: 2.1 Methodsmempty :: Last a #mappend :: Last a -> Last a -> Last a #mconcat :: [Last a] -> Last a # Monoid b => Monoid (a -> b) Since: 2.1 Methodsmempty :: a -> b #mappend :: (a -> b) -> (a -> b) -> a -> b #mconcat :: [a -> b] -> a -> b # (Monoid a, Monoid b) => Monoid (a, b) Since: 2.1 Methodsmempty :: (a, b) #mappend :: (a, b) -> (a, b) -> (a, b) #mconcat :: [(a, b)] -> (a, b) # (Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) Since: 2.1 Methodsmempty :: (a, b, c) #mappend :: (a, b, c) -> (a, b, c) -> (a, b, c) #mconcat :: [(a, b, c)] -> (a, b, c) # Monoid a => Monoid (Const k a b) Methodsmempty :: Const k a b #mappend :: Const k a b -> Const k a b -> Const k a b #mconcat :: [Const k a b] -> Const k a b # Alternative f => Monoid (Alt * f a) Since: 4.8.0.0 Methodsmempty :: Alt * f a #mappend :: Alt * f a -> Alt * f a -> Alt * f a #mconcat :: [Alt * f a] -> Alt * f a # (Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) Since: 2.1 Methodsmempty :: (a, b, c, d) #mappend :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) #mconcat :: [(a, b, c, d)] -> (a, b, c, d) # (Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) Since: 2.1 Methodsmempty :: (a, b, c, d, e) #mappend :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) #mconcat :: [(a, b, c, d, e)] -> (a, b, c, d, e) #

data Dual a :: * -> * #

The dual of a Monoid, obtained by swapping the arguments of mappend.

Instances

 Since: 4.8.0.0 Methods(>>=) :: Dual a -> (a -> Dual b) -> Dual b #(>>) :: Dual a -> Dual b -> Dual b #return :: a -> Dual a #fail :: String -> Dual a # Since: 4.8.0.0 Methodsfmap :: (a -> b) -> Dual a -> Dual b #(<$) :: a -> Dual b -> Dual a # Since: 4.8.0.0 Methodspure :: a -> Dual a #(<*>) :: Dual (a -> b) -> Dual a -> Dual b #liftA2 :: (a -> b -> c) -> Dual a -> Dual b -> Dual c #(*>) :: Dual a -> Dual b -> Dual b #(<*) :: Dual a -> Dual b -> Dual a # Since: 4.8.0.0 Methodsfold :: Monoid m => Dual m -> m #foldMap :: Monoid m => (a -> m) -> Dual a -> m #foldr :: (a -> b -> b) -> b -> Dual a -> b #foldr' :: (a -> b -> b) -> b -> Dual a -> b #foldl :: (b -> a -> b) -> b -> Dual a -> b #foldl' :: (b -> a -> b) -> b -> Dual a -> b #foldr1 :: (a -> a -> a) -> Dual a -> a #foldl1 :: (a -> a -> a) -> Dual a -> a #toList :: Dual a -> [a] #null :: Dual a -> Bool #length :: Dual a -> Int #elem :: Eq a => a -> Dual a -> Bool #maximum :: Ord a => Dual a -> a #minimum :: Ord a => Dual a -> a #sum :: Num a => Dual a -> a #product :: Num a => Dual a -> a # Since: 4.8.0.0 Methodstraverse :: Applicative f => (a -> f b) -> Dual a -> f (Dual b) #sequenceA :: Applicative f => Dual (f a) -> f (Dual a) #mapM :: Monad m => (a -> m b) -> Dual a -> m (Dual b) #sequence :: Monad m => Dual (m a) -> m (Dual a) # Bounded a => Bounded (Dual a) Methods Eq a => Eq (Dual a) Methods(==) :: Dual a -> Dual a -> Bool #(/=) :: Dual a -> Dual a -> Bool # Ord a => Ord (Dual a) Methodscompare :: Dual a -> Dual a -> Ordering #(<) :: Dual a -> Dual a -> Bool #(<=) :: Dual a -> Dual a -> Bool #(>) :: Dual a -> Dual a -> Bool #(>=) :: Dual a -> Dual a -> Bool #max :: Dual a -> Dual a -> Dual a #min :: Dual a -> Dual a -> Dual a # Read a => Read (Dual a) MethodsreadsPrec :: Int -> ReadS (Dual a) #readList :: ReadS [Dual a] # Show a => Show (Dual a) MethodsshowsPrec :: Int -> Dual a -> ShowS #show :: Dual a -> String #showList :: [Dual a] -> ShowS # Generic (Dual a) Associated Typestype Rep (Dual a) :: * -> * # Methodsfrom :: Dual a -> Rep (Dual a) x #to :: Rep (Dual a) x -> Dual a # Semigroup a => Semigroup (Dual a) Since: 4.9.0.0 Methods(<>) :: Dual a -> Dual a -> Dual a #sconcat :: NonEmpty (Dual a) -> Dual a #stimes :: Integral b => b -> Dual a -> Dual a # Monoid a => Monoid (Dual a) Since: 2.1 Methodsmempty :: Dual a #mappend :: Dual a -> Dual a -> Dual a #mconcat :: [Dual a] -> Dual a # Associated Typestype Rep1 Dual (f :: Dual -> *) :: k -> * # Methodsfrom1 :: f a -> Rep1 Dual f a #to1 :: Rep1 Dual f a -> f a # type Rep (Dual a) type Rep (Dual a) = D1 * (MetaData "Dual" "Data.Monoid" "base" True) (C1 * (MetaCons "Dual" PrefixI True) (S1 * (MetaSel (Just Symbol "getDual") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * a))) type Rep1 * Dual type Rep1 * Dual = D1 * (MetaData "Dual" "Data.Monoid" "base" True) (C1 * (MetaCons "Dual" PrefixI True) (S1 * (MetaSel (Just Symbol "getDual") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1)) data Endo a :: * -> * # The monoid of endomorphisms under composition. Instances  Generic (Endo a) Associated Typestype Rep (Endo a) :: * -> * # Methodsfrom :: Endo a -> Rep (Endo a) x #to :: Rep (Endo a) x -> Endo a # Since: 4.9.0.0 Methods(<>) :: Endo a -> Endo a -> Endo a #sconcat :: NonEmpty (Endo a) -> Endo a #stimes :: Integral b => b -> Endo a -> Endo a # Monoid (Endo a) Since: 2.1 Methodsmempty :: Endo a #mappend :: Endo a -> Endo a -> Endo a #mconcat :: [Endo a] -> Endo a # type Rep (Endo a) type Rep (Endo a) = D1 * (MetaData "Endo" "Data.Monoid" "base" True) (C1 * (MetaCons "Endo" PrefixI True) (S1 * (MetaSel (Just Symbol "appEndo") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (a -> a)))) data All :: * # Boolean monoid under conjunction (&&). Instances  Methods Methods(==) :: All -> All -> Bool #(/=) :: All -> All -> Bool # Methodscompare :: All -> All -> Ordering #(<) :: All -> All -> Bool #(<=) :: All -> All -> Bool #(>) :: All -> All -> Bool #(>=) :: All -> All -> Bool #max :: All -> All -> All #min :: All -> All -> All # Methods MethodsshowsPrec :: Int -> All -> ShowS #show :: All -> String #showList :: [All] -> ShowS # Associated Typestype Rep All :: * -> * # Methodsfrom :: All -> Rep All x #to :: Rep All x -> All # Since: 4.9.0.0 Methods(<>) :: All -> All -> All #stimes :: Integral b => b -> All -> All # Since: 2.1 Methodsmappend :: All -> All -> All #mconcat :: [All] -> All # type Rep All type Rep All = D1 * (MetaData "All" "Data.Monoid" "base" True) (C1 * (MetaCons "All" PrefixI True) (S1 * (MetaSel (Just Symbol "getAll") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Bool))) data Any :: * # Boolean monoid under disjunction (||). Instances  Methods Methods(==) :: Any -> Any -> Bool #(/=) :: Any -> Any -> Bool # Methodscompare :: Any -> Any -> Ordering #(<) :: Any -> Any -> Bool #(<=) :: Any -> Any -> Bool #(>) :: Any -> Any -> Bool #(>=) :: Any -> Any -> Bool #max :: Any -> Any -> Any #min :: Any -> Any -> Any # Methods MethodsshowsPrec :: Int -> Any -> ShowS #show :: Any -> String #showList :: [Any] -> ShowS # Associated Typestype Rep Any :: * -> * # Methodsfrom :: Any -> Rep Any x #to :: Rep Any x -> Any # Since: 4.9.0.0 Methods(<>) :: Any -> Any -> Any #stimes :: Integral b => b -> Any -> Any # Since: 2.1 Methodsmappend :: Any -> Any -> Any #mconcat :: [Any] -> Any # type Rep Any type Rep Any = D1 * (MetaData "Any" "Data.Monoid" "base" True) (C1 * (MetaCons "Any" PrefixI True) (S1 * (MetaSel (Just Symbol "getAny") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * Bool))) data Sum a :: * -> * # Monoid under addition. Instances  Since: 4.8.0.0 Methods(>>=) :: Sum a -> (a -> Sum b) -> Sum b #(>>) :: Sum a -> Sum b -> Sum b #return :: a -> Sum a #fail :: String -> Sum a # Since: 4.8.0.0 Methodsfmap :: (a -> b) -> Sum a -> Sum b #(<$) :: a -> Sum b -> Sum a # Since: 4.8.0.0 Methodspure :: a -> Sum a #(<*>) :: Sum (a -> b) -> Sum a -> Sum b #liftA2 :: (a -> b -> c) -> Sum a -> Sum b -> Sum c #(*>) :: Sum a -> Sum b -> Sum b #(<*) :: Sum a -> Sum b -> Sum a # Since: 4.8.0.0 Methodsfold :: Monoid m => Sum m -> m #foldMap :: Monoid m => (a -> m) -> Sum a -> m #foldr :: (a -> b -> b) -> b -> Sum a -> b #foldr' :: (a -> b -> b) -> b -> Sum a -> b #foldl :: (b -> a -> b) -> b -> Sum a -> b #foldl' :: (b -> a -> b) -> b -> Sum a -> b #foldr1 :: (a -> a -> a) -> Sum a -> a #foldl1 :: (a -> a -> a) -> Sum a -> a #toList :: Sum a -> [a] #null :: Sum a -> Bool #length :: Sum a -> Int #elem :: Eq a => a -> Sum a -> Bool #maximum :: Ord a => Sum a -> a #minimum :: Ord a => Sum a -> a #sum :: Num a => Sum a -> a #product :: Num a => Sum a -> a # Since: 4.8.0.0 Methodstraverse :: Applicative f => (a -> f b) -> Sum a -> f (Sum b) #sequenceA :: Applicative f => Sum (f a) -> f (Sum a) #mapM :: Monad m => (a -> m b) -> Sum a -> m (Sum b) #sequence :: Monad m => Sum (m a) -> m (Sum a) # Bounded a => Bounded (Sum a) MethodsminBound :: Sum a #maxBound :: Sum a # Eq a => Eq (Sum a) Methods(==) :: Sum a -> Sum a -> Bool #(/=) :: Sum a -> Sum a -> Bool # Num a => Num (Sum a) Methods(+) :: Sum a -> Sum a -> Sum a #(-) :: Sum a -> Sum a -> Sum a #(*) :: Sum a -> Sum a -> Sum a #negate :: Sum a -> Sum a #abs :: Sum a -> Sum a #signum :: Sum a -> Sum a # Ord a => Ord (Sum a) Methodscompare :: Sum a -> Sum a -> Ordering #(<) :: Sum a -> Sum a -> Bool #(<=) :: Sum a -> Sum a -> Bool #(>) :: Sum a -> Sum a -> Bool #(>=) :: Sum a -> Sum a -> Bool #max :: Sum a -> Sum a -> Sum a #min :: Sum a -> Sum a -> Sum a # Read a => Read (Sum a) MethodsreadsPrec :: Int -> ReadS (Sum a) #readList :: ReadS [Sum a] #readPrec :: ReadPrec (Sum a) # Show a => Show (Sum a) MethodsshowsPrec :: Int -> Sum a -> ShowS #show :: Sum a -> String #showList :: [Sum a] -> ShowS # Generic (Sum a) Associated Typestype Rep (Sum a) :: * -> * # Methodsfrom :: Sum a -> Rep (Sum a) x #to :: Rep (Sum a) x -> Sum a # Num a => Semigroup (Sum a) Since: 4.9.0.0 Methods(<>) :: Sum a -> Sum a -> Sum a #sconcat :: NonEmpty (Sum a) -> Sum a #stimes :: Integral b => b -> Sum a -> Sum a # Num a => Monoid (Sum a) Since: 2.1 Methodsmempty :: Sum a #mappend :: Sum a -> Sum a -> Sum a #mconcat :: [Sum a] -> Sum a # Associated Typestype Rep1 Sum (f :: Sum -> *) :: k -> * # Methodsfrom1 :: f a -> Rep1 Sum f a #to1 :: Rep1 Sum f a -> f a # type Rep (Sum a) type Rep (Sum a) = D1 * (MetaData "Sum" "Data.Monoid" "base" True) (C1 * (MetaCons "Sum" PrefixI True) (S1 * (MetaSel (Just Symbol "getSum") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * a))) type Rep1 * Sum type Rep1 * Sum = D1 * (MetaData "Sum" "Data.Monoid" "base" True) (C1 * (MetaCons "Sum" PrefixI True) (S1 * (MetaSel (Just Symbol "getSum") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))

data Product a :: * -> * #

Monoid under multiplication.

Instances

 Since: 4.8.0.0 Methods(>>=) :: Product a -> (a -> Product b) -> Product b #(>>) :: Product a -> Product b -> Product b #return :: a -> Product a #fail :: String -> Product a # Since: 4.8.0.0 Methodsfmap :: (a -> b) -> Product a -> Product b #(<\$) :: a -> Product b -> Product a # Since: 4.8.0.0 Methodspure :: a -> Product a #(<*>) :: Product (a -> b) -> Product a -> Product b #liftA2 :: (a -> b -> c) -> Product a -> Product b -> Product c #(*>) :: Product a -> Product b -> Product b #(<*) :: Product a -> Product b -> Product a # Since: 4.8.0.0 Methodsfold :: Monoid m => Product m -> m #foldMap :: Monoid m => (a -> m) -> Product a -> m #foldr :: (a -> b -> b) -> b -> Product a -> b #foldr' :: (a -> b -> b) -> b -> Product a -> b #foldl :: (b -> a -> b) -> b -> Product a -> b #foldl' :: (b -> a -> b) -> b -> Product a -> b #foldr1 :: (a -> a -> a) -> Product a -> a #foldl1 :: (a -> a -> a) -> Product a -> a #toList :: Product a -> [a] #null :: Product a -> Bool #length :: Product a -> Int #elem :: Eq a => a -> Product a -> Bool #maximum :: Ord a => Product a -> a #minimum :: Ord a => Product a -> a #sum :: Num a => Product a -> a #product :: Num a => Product a -> a # Since: 4.8.0.0 Methodstraverse :: Applicative f => (a -> f b) -> Product a -> f (Product b) #sequenceA :: Applicative f => Product (f a) -> f (Product a) #mapM :: Monad m => (a -> m b) -> Product a -> m (Product b) #sequence :: Monad m => Product (m a) -> m (Product a) # Bounded a => Bounded (Product a) Methods Eq a => Eq (Product a) Methods(==) :: Product a -> Product a -> Bool #(/=) :: Product a -> Product a -> Bool # Num a => Num (Product a) Methods(+) :: Product a -> Product a -> Product a #(-) :: Product a -> Product a -> Product a #(*) :: Product a -> Product a -> Product a #negate :: Product a -> Product a #abs :: Product a -> Product a #signum :: Product a -> Product a # Ord a => Ord (Product a) Methodscompare :: Product a -> Product a -> Ordering #(<) :: Product a -> Product a -> Bool #(<=) :: Product a -> Product a -> Bool #(>) :: Product a -> Product a -> Bool #(>=) :: Product a -> Product a -> Bool #max :: Product a -> Product a -> Product a #min :: Product a -> Product a -> Product a # Read a => Read (Product a) MethodsreadsPrec :: Int -> ReadS (Product a) # Show a => Show (Product a) MethodsshowsPrec :: Int -> Product a -> ShowS #show :: Product a -> String #showList :: [Product a] -> ShowS # Associated Typestype Rep (Product a) :: * -> * # Methodsfrom :: Product a -> Rep (Product a) x #to :: Rep (Product a) x -> Product a # Num a => Semigroup (Product a) Since: 4.9.0.0 Methods(<>) :: Product a -> Product a -> Product a #sconcat :: NonEmpty (Product a) -> Product a #stimes :: Integral b => b -> Product a -> Product a # Num a => Monoid (Product a) Since: 2.1 Methodsmappend :: Product a -> Product a -> Product a #mconcat :: [Product a] -> Product a # Associated Typestype Rep1 Product (f :: Product -> *) :: k -> * # Methodsfrom1 :: f a -> Rep1 Product f a #to1 :: Rep1 Product f a -> f a # type Rep (Product a) type Rep (Product a) = D1 * (MetaData "Product" "Data.Monoid" "base" True) (C1 * (MetaCons "Product" PrefixI True) (S1 * (MetaSel (Just Symbol "getProduct") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * a))) type Rep1 * Product type Rep1 * Product = D1 * (MetaData "Product" "Data.Monoid" "base" True) (C1 * (MetaCons "Product" PrefixI True) (S1 * (MetaSel (Just Symbol "getProduct") NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))