-- 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.4 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: -- --
-- a <> zero = zero <> a = zero ---- --
-- a <> b <> c = (a <> b) <> c = a <> (b <> c) --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 (<>) and -- zero. zconcat :: Zero a => [a] -> a -- | Monoid under multiplication. newtype Product a :: * -> * Product :: a -> Product a [getProduct] :: Product a -> a -- | Boolean monoid under disjunction (||). newtype Any :: * Any :: Bool -> Any [getAny] :: Any -> Bool -- | Boolean monoid under conjunction (&&). 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 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)