-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Semigroups with absorption
--   
--   <a>Monoid</a> is a <a>Semigroup</a> glued with a neutral element
--   called <a>mempty</a>. In the same idea, <a>Zero</a> is a
--   <a>Semigroup</a> glued with an absorbing element called <a>zero</a>.
--   
--   Keep in mind that <a>Zero</a> requires <a>Semigroup</a>. If you have
--   <a>Semigroup</a> defined to work with <a>Monoid</a>, you might end up
--   with no way to implement <a>Zero</a>. That’s why the <a>Semigroup</a>
--   instance for <a>Maybe</a> is confusing, because it relies on
--   <a>Monoid</a>, and cannot be used with <a>Zero</a>. <a>Success</a> is
--   the <a>Zero</a> equivalent of <a>Maybe</a> + <a>Monoid</a>.
@package zero
@version 0.1.4


module Data.Zero

-- | <a>Semigroup</a> with a <a>zero</a> element. It’s important to
--   understand that the standard <a>Semigroup</a> types – i.e.
--   <a>Maybe</a> and so on – are already biased, because they’re
--   <a>Monoid</a>s. That’s why you’ll find a few <a>Zero</a> instances.
--   
--   Should satisfies the following laws:
--   
--   <h4>Annihilation</h4>
--   
--   <pre>
--   a <a>&lt;&gt;</a> <a>zero</a> = <a>zero</a> <a>&lt;&gt;</a> a = <a>zero</a>
--   </pre>
--   
--   <h4>Associativity</h4>
--   
--   <pre>
--   a <a>&lt;&gt;</a> b <a>&lt;&gt;</a> c = (a <a>&lt;&gt;</a> b) <a>&lt;&gt;</a> c = a <a>&lt;&gt;</a> (b <a>&lt;&gt;</a> c)
--   </pre>
class (Semigroup a) => Zero a where zconcat [] = zero zconcat (x : xs) = foldr (<>) x xs

-- | The zero element.
zero :: Zero a => a

-- | Concat all the elements according to (<a>&lt;&gt;</a>) and
--   <a>zero</a>.
zconcat :: Zero a => [a] -> a

-- | Concat all the elements according to (<a>&lt;&gt;</a>) and
--   <a>zero</a>.
zconcat :: Zero a => [a] -> a

-- | Monoid under multiplication.
newtype Product a :: * -> *
Product :: a -> Product a
[getProduct] :: Product a -> a

-- | Boolean monoid under disjunction (<a>||</a>).
newtype Any :: *
Any :: Bool -> Any
[getAny] :: Any -> Bool

-- | Boolean monoid under conjunction (<a>&amp;&amp;</a>).
newtype All :: *
All :: Bool -> All
[getAll] :: All -> Bool

-- | <a>Zero</a> for <a>Maybe</a>.
--   
--   Called <a>Success</a> because of the absorbing law:
--   
--   <pre>
--   <a>Success</a> (<a>Just</a> a) <a>&lt;&gt;</a> <a>Success</a> <a>Nothing</a> = <a>Nothing</a>
--   </pre>
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 Data.Zero.Zero ()
instance GHC.Num.Num a => Data.Zero.Zero (Data.Monoid.Product a)
instance Data.Zero.Zero Data.Monoid.Any
instance Data.Zero.Zero Data.Monoid.All
instance Data.Semigroup.Semigroup a => Data.Semigroup.Semigroup (Data.Zero.Success a)
instance Data.Semigroup.Semigroup a => Data.Zero.Zero (Data.Zero.Success a)
