packages feed

zero 0.1.1 → 0.1.2

raw patch · 3 files changed

+27/−23 lines, 3 files

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+## 0.1.2++- Replace hard-coded wrappers by Data.Monoid’s ones.+- Fixed typo.+ ## 0.1.1  - Added Any.
src/Data/Zero.hs view
@@ -8,11 +8,23 @@ -- Portability : portable ----------------------------------------------------------------------------- -module Data.Zero where+module Data.Zero (+    -- * Semigroups with absorbing element+    Zero(..)+    -- * Num wrappers+  , Product(..)+    -- * Boolean wrappers+  , Any(..)+  , All(..)+    -- * Maybe wrappers+  , Success(..)+  , success+  , failure+  ) where  import Control.Monad.Fix ( MonadFix )+import Data.Monoid ( All(..), Any(..), Product(..) ) import Data.Semigroup ( Semigroup(..) )-import GHC.Generics ( Generic )  -- |'Semigroup' with a 'zero' element. It’s important to understand that the -- standard 'Semigroup' types – i.e. 'Maybe' and so on – are already biased,@@ -20,7 +32,7 @@ -- -- Should satisfies the following laws: ----- ==== Annhilation+-- ==== Annihilation -- -- @ a '<>' 'zero' = 'zero' '<>' a = 'zero' @ --@@ -41,35 +53,22 @@ instance Zero () where   zero = () --- |'Zero' under multiplication.-newtype Product a = Product { getProduct :: a }-  deriving (Bounded,Eq,Generic,Num,Ord,Read,Show)--instance (Num a) => Semigroup (Product a) where-  Product a <> Product b = Product $ a * b- instance (Num a) => Zero (Product a) where   zero = Product 0 --- |'Zero' under boolean logical or.-newtype Any = Any { getAny :: Bool } deriving (Bounded,Eq,Generic,Ord,Read,Show)--instance Semigroup Any where-  Any a <> Any b = Any $ a || b- instance Zero Any where   zero = Any True --- |'Zero' under boolean logical and.-newtype All = All { getAll :: Bool} deriving (Bounded,Eq,Generic,Ord,Read,Show)--instance Semigroup All where-  All a <> All b = All $ a && b- instance Zero All where   zero = All False  -- |'Zero' for 'Maybe'.+--+-- Called 'Success' because of the absorbing law:+--+-- @+--   'Success' ('Just' a) '<>' 'Success' 'Nothing' = 'Nothing'+-- @ newtype Success a = Success { getSuccess :: Maybe a }   deriving (Applicative,Eq,Foldable,Functor,Monad,MonadFix,Ord,Traversable,Read,Show) 
zero.cabal view
@@ -1,5 +1,5 @@ name:                zero-version:             0.1.1+version:             0.1.2 synopsis:            Semigroups with absorption description:         'Monoid' is a 'Semigroup' glued with a neutral element                      called 'mempty'. In the same idea, 'Zero' is a 'Semigroup'