Copyright | (C) 2015 Dimitri Sabadie |
---|---|
License | BSD3 |
Maintainer | Dimitri Sabadie <dimitri.sabadie@gmail.com> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Semigroups with absorbing element
class Semigroup a => Zero a where Source #
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 Monoid
s. 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)
The zero element.
Num wrappers
Monoid under multiplication.
>>>
getProduct (Product 3 <> Product 4 <> mempty)
12
Product | |
|
Instances
Monad Product | Since: base-4.8.0.0 |
Functor Product | Since: base-4.8.0.0 |
MonadFix Product | Since: base-4.8.0.0 |
Defined in Control.Monad.Fix | |
Applicative Product | Since: base-4.8.0.0 |
Foldable Product | Since: base-4.8.0.0 |
Defined in Data.Foldable 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 # elem :: Eq a => a -> Product a -> Bool # maximum :: Ord a => Product a -> a # minimum :: Ord a => Product a -> a # | |
Traversable Product | Since: base-4.8.0.0 |
Bounded a => Bounded (Product a) | Since: base-2.1 |
Eq a => Eq (Product a) | Since: base-2.1 |
Num a => Num (Product a) | Since: base-4.7.0.0 |
Defined in Data.Semigroup.Internal | |
Ord a => Ord (Product a) | Since: base-2.1 |
Defined in Data.Semigroup.Internal | |
Read a => Read (Product a) | Since: base-2.1 |
Show a => Show (Product a) | Since: base-2.1 |
Generic (Product a) | |
Num a => Semigroup (Product a) | Since: base-4.9.0.0 |
Num a => Monoid (Product a) | Since: base-2.1 |
Num a => Zero (Product a) Source # | |
Generic1 Product | |
type Rep (Product a) | Since: base-4.7.0.0 |
Defined in Data.Semigroup.Internal | |
type Rep1 Product | Since: base-4.7.0.0 |
Defined in Data.Semigroup.Internal |
Boolean wrappers
Boolean monoid under disjunction (||
).
>>>
getAny (Any True <> mempty <> Any False)
True
>>>
getAny (mconcat (map (\x -> Any (even x)) [2,4,6,7,8]))
True
Boolean monoid under conjunction (&&
).
>>>
getAll (All True <> mempty <> All False)
False
>>>
getAll (mconcat (map (\x -> All (even x)) [2,4,6,7,8]))
False
Maybe wrappers
Success | |
|
Instances
Monad Success Source # | |
Functor Success Source # | |
MonadFix Success Source # | |
Applicative Success Source # | |
Foldable Success Source # | |
Defined in Data.Zero 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 # elem :: Eq a => a -> Success a -> Bool # maximum :: Ord a => Success a -> a # minimum :: Ord a => Success a -> a # | |
Traversable Success Source # | |
Eq a => Eq (Success a) Source # | |
Ord a => Ord (Success a) Source # | |
Defined in Data.Zero | |
Read a => Read (Success a) Source # | |
Show a => Show (Success a) Source # | |
Semigroup a => Semigroup (Success a) Source # | |
Semigroup a => Zero (Success a) Source # | |