zero-0.1.4: Semigroups with absorption

Copyright(C) 2015 Dimitri Sabadie
LicenseBSD3
MaintainerDimitri Sabadie <dimitri.sabadie@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Zero

Contents

Description

 

Synopsis

Semigroups with absorbing element

class Semigroup a => Zero a where #

Semigroup with a zero element. It’s important to understand that the standard Semigroup types – i.e. Maybe and so on – are already biased, because they’re Monoids. That’s why you’ll find a few Zero instances.

Should satisfies the following laws:

Annihilation

 a <> zero = zero <> a = zero

Associativity

 a <> b <> c = (a <> b) <> c = a <> (b <> c)

Minimal complete definition

zero

Methods

zero :: a #

The zero element.

zconcat :: [a] -> a #

Concat all the elements according to (<>) and zero.

zconcat :: [a] -> a #

Concat all the elements according to (<>) and zero.

Instances

Zero () # 

Methods

zero :: () #

zconcat :: [()] -> () #

Zero All # 

Methods

zero :: All #

zconcat :: [All] -> All #

Zero Any # 

Methods

zero :: Any #

zconcat :: [Any] -> Any #

Num a => Zero (Product a) # 

Methods

zero :: Product a #

zconcat :: [Product a] -> Product a #

Semigroup a => Zero (Success a) # 

Methods

zero :: Success a #

zconcat :: [Success a] -> Success a #

Num wrappers

newtype Product a :: * -> * #

Monoid under multiplication.

Constructors

Product 

Fields

Instances

Monad Product

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 #

Functor Product

Since: 4.8.0.0

Methods

fmap :: (a -> b) -> Product a -> Product b #

(<$) :: a -> Product b -> Product a #

MonadFix Product

Since: 4.8.0.0

Methods

mfix :: (a -> Product a) -> Product a #

Applicative Product

Since: 4.8.0.0

Methods

pure :: 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 #

Foldable Product

Since: 4.8.0.0

Methods

fold :: 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 #

Traversable Product

Since: 4.8.0.0

Methods

traverse :: 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) 
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 #

fromInteger :: Integer -> Product a #

Ord a => Ord (Product a) 

Methods

compare :: 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) 
Show a => Show (Product a) 

Methods

showsPrec :: Int -> Product a -> ShowS #

show :: Product a -> String #

showList :: [Product a] -> ShowS #

Generic (Product a) 

Associated Types

type Rep (Product a) :: * -> * #

Methods

from :: 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

Methods

mempty :: Product a #

mappend :: Product a -> Product a -> Product a #

mconcat :: [Product a] -> Product a #

Num a => Zero (Product a) # 

Methods

zero :: Product a #

zconcat :: [Product a] -> Product a #

Generic1 * Product 

Associated Types

type Rep1 Product (f :: Product -> *) :: k -> * #

Methods

from1 :: 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))

Boolean wrappers

newtype Any :: * #

Boolean monoid under disjunction (||).

Constructors

Any 

Fields

Instances

Bounded Any 

Methods

minBound :: Any #

maxBound :: Any #

Eq Any 

Methods

(==) :: Any -> Any -> Bool #

(/=) :: Any -> Any -> Bool #

Ord Any 

Methods

compare :: Any -> Any -> Ordering #

(<) :: Any -> Any -> Bool #

(<=) :: Any -> Any -> Bool #

(>) :: Any -> Any -> Bool #

(>=) :: Any -> Any -> Bool #

max :: Any -> Any -> Any #

min :: Any -> Any -> Any #

Read Any 
Show Any 

Methods

showsPrec :: Int -> Any -> ShowS #

show :: Any -> String #

showList :: [Any] -> ShowS #

Generic Any 

Associated Types

type Rep Any :: * -> * #

Methods

from :: Any -> Rep Any x #

to :: Rep Any x -> Any #

Semigroup Any

Since: 4.9.0.0

Methods

(<>) :: Any -> Any -> Any #

sconcat :: NonEmpty Any -> Any #

stimes :: Integral b => b -> Any -> Any #

Monoid Any

Since: 2.1

Methods

mempty :: Any #

mappend :: Any -> Any -> Any #

mconcat :: [Any] -> Any #

Zero Any # 

Methods

zero :: Any #

zconcat :: [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)))

newtype All :: * #

Boolean monoid under conjunction (&&).

Constructors

All 

Fields

Instances

Bounded All 

Methods

minBound :: All #

maxBound :: All #

Eq All 

Methods

(==) :: All -> All -> Bool #

(/=) :: All -> All -> Bool #

Ord All 

Methods

compare :: All -> All -> Ordering #

(<) :: All -> All -> Bool #

(<=) :: All -> All -> Bool #

(>) :: All -> All -> Bool #

(>=) :: All -> All -> Bool #

max :: All -> All -> All #

min :: All -> All -> All #

Read All 
Show All 

Methods

showsPrec :: Int -> All -> ShowS #

show :: All -> String #

showList :: [All] -> ShowS #

Generic All 

Associated Types

type Rep All :: * -> * #

Methods

from :: All -> Rep All x #

to :: Rep All x -> All #

Semigroup All

Since: 4.9.0.0

Methods

(<>) :: All -> All -> All #

sconcat :: NonEmpty All -> All #

stimes :: Integral b => b -> All -> All #

Monoid All

Since: 2.1

Methods

mempty :: All #

mappend :: All -> All -> All #

mconcat :: [All] -> All #

Zero All # 

Methods

zero :: All #

zconcat :: [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)))

Maybe wrappers

newtype Success a #

Zero for Maybe.

Called Success because of the absorbing law:

  Success (Just a) <> Success Nothing = Nothing

Constructors

Success 

Fields

Instances

Monad Success # 

Methods

(>>=) :: Success a -> (a -> Success b) -> Success b #

(>>) :: Success a -> Success b -> Success b #

return :: a -> Success a #

fail :: String -> Success a #

Functor Success # 

Methods

fmap :: (a -> b) -> Success a -> Success b #

(<$) :: a -> Success b -> Success a #

MonadFix Success # 

Methods

mfix :: (a -> Success a) -> Success a #

Applicative Success # 

Methods

pure :: a -> Success a #

(<*>) :: Success (a -> b) -> Success a -> Success b #

liftA2 :: (a -> b -> c) -> Success a -> Success b -> Success c #

(*>) :: Success a -> Success b -> Success b #

(<*) :: Success a -> Success b -> Success a #

Foldable Success # 

Methods

fold :: Monoid m => Success m -> m #

foldMap :: Monoid m => (a -> m) -> Success a -> m #

foldr :: (a -> b -> b) -> b -> Success a -> b #

foldr' :: (a -> b -> b) -> b -> Success a -> b #

foldl :: (b -> a -> b) -> b -> Success a -> b #

foldl' :: (b -> a -> b) -> b -> Success a -> b #

foldr1 :: (a -> a -> a) -> Success a -> a #

foldl1 :: (a -> a -> a) -> Success a -> a #

toList :: Success a -> [a] #

null :: Success a -> Bool #

length :: Success a -> Int #

elem :: Eq a => a -> Success a -> Bool #

maximum :: Ord a => Success a -> a #

minimum :: Ord a => Success a -> a #

sum :: Num a => Success a -> a #

product :: Num a => Success a -> a #

Traversable Success # 

Methods

traverse :: Applicative f => (a -> f b) -> Success a -> f (Success b) #

sequenceA :: Applicative f => Success (f a) -> f (Success a) #

mapM :: Monad m => (a -> m b) -> Success a -> m (Success b) #

sequence :: Monad m => Success (m a) -> m (Success a) #

Eq a => Eq (Success a) # 

Methods

(==) :: Success a -> Success a -> Bool #

(/=) :: Success a -> Success a -> Bool #

Ord a => Ord (Success a) # 

Methods

compare :: Success a -> Success a -> Ordering #

(<) :: Success a -> Success a -> Bool #

(<=) :: Success a -> Success a -> Bool #

(>) :: Success a -> Success a -> Bool #

(>=) :: Success a -> Success a -> Bool #

max :: Success a -> Success a -> Success a #

min :: Success a -> Success a -> Success a #

Read a => Read (Success a) # 
Show a => Show (Success a) # 

Methods

showsPrec :: Int -> Success a -> ShowS #

show :: Success a -> String #

showList :: [Success a] -> ShowS #

Semigroup a => Semigroup (Success a) # 

Methods

(<>) :: Success a -> Success a -> Success a #

sconcat :: NonEmpty (Success a) -> Success a #

stimes :: Integral b => b -> Success a -> Success a #

Semigroup a => Zero (Success a) # 

Methods

zero :: Success a #

zconcat :: [Success a] -> Success a #

success :: a -> Success a #

A successful value.

failure :: Success a #

A failure.