-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Semigroups with absorption -- -- Monoid is a Semigroup glued with a neutral element -- called mempty. In the same idea, Zero is a -- Semigroup glued with an absorbing element called zero. -- -- Keep in mind that Zero requires Semigroup. If you have -- Semigroup defined to work with Monoid, you might end up -- with no way to implement Zero. That’s why the Semigroup -- instance for Maybe is confusing, because it relies on -- Monoid, and cannot be used with Zero. Success is -- the Zero equivalent of Maybe + Monoid. @package zero @version 0.1.5 module Data.Zero -- | 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)
--   
class (Semigroup a) => Zero a -- | The zero element. zero :: Zero a => a -- | Concat all the elements according to (<>) and -- zero. zconcat :: Zero a => [a] -> a -- | Concat all the elements according to (<>) and -- zero. zconcat :: Zero a => [a] -> a -- | Monoid under multiplication. -- --
--   >>> getProduct (Product 3 <> Product 4 <> mempty)
--   12
--   
newtype Product a Product :: a -> Product a [getProduct] :: Product a -> a -- | Boolean monoid under disjunction (||). -- --
--   >>> getAny (Any True <> mempty <> Any False)
--   True
--   
-- --
--   >>> getAny (mconcat (map (\x -> Any (even x)) [2,4,6,7,8]))
--   True
--   
newtype Any Any :: Bool -> Any [getAny] :: Any -> Bool -- | Boolean monoid under conjunction (&&). -- --
--   >>> getAll (All True <> mempty <> All False)
--   False
--   
-- --
--   >>> getAll (mconcat (map (\x -> All (even x)) [2,4,6,7,8]))
--   False
--   
newtype All All :: Bool -> All [getAll] :: All -> Bool -- | Zero for Maybe. -- -- Called Success because of the absorbing law: -- --
--   Success (Just a) <> Success Nothing = Nothing
--   
newtype Success a Success :: Maybe a -> Success a [getSuccess] :: Success a -> Maybe a -- | A successful value. success :: a -> Success a -- | A failure. failure :: Success a instance GHC.Show.Show a => GHC.Show.Show (Data.Zero.Success a) instance GHC.Read.Read a => GHC.Read.Read (Data.Zero.Success a) instance Data.Traversable.Traversable Data.Zero.Success instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Zero.Success a) instance Control.Monad.Fix.MonadFix Data.Zero.Success instance GHC.Base.Monad Data.Zero.Success instance GHC.Base.Functor Data.Zero.Success instance Data.Foldable.Foldable Data.Zero.Success instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Zero.Success a) instance GHC.Base.Applicative Data.Zero.Success instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Data.Zero.Success a) instance GHC.Base.Semigroup a => Data.Zero.Zero (Data.Zero.Success a) instance Data.Zero.Zero () instance GHC.Num.Num a => Data.Zero.Zero (Data.Semigroup.Internal.Product a) instance Data.Zero.Zero Data.Semigroup.Internal.Any instance Data.Zero.Zero Data.Semigroup.Internal.All