packages feed

bool-extras 0.2.0 → 0.3.0

raw patch · 2 files changed

+18/−8 lines, 2 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

+ Data.Bool.Extras: mwhenM :: (Monad m, Monoid a) => m a -> Bool -> m a
- Data.Bool.Extras: mwhen :: (Monoid a) => a -> Bool -> a
+ Data.Bool.Extras: mwhen :: Monoid a => a -> Bool -> a
- Data.Bool.Extras: whenA :: (Arrow a) => a b b -> Bool -> a b b
+ Data.Bool.Extras: whenA :: Arrow a => a b b -> Bool -> a b b
- Data.Bool.Extras: whenC :: (Category cat) => cat b b -> Bool -> cat b b
+ Data.Bool.Extras: whenC :: Category cat => cat a a -> Bool -> cat a a
- Data.Bool.Extras: whenM :: (Monad m) => (b -> m b) -> Bool -> (b -> m b)
+ Data.Bool.Extras: whenM :: Monad m => (a -> m a) -> Bool -> (a -> m a)

Files

bool-extras.cabal view
@@ -1,5 +1,5 @@ name:                bool-extras-version:             0.2.0+version:             0.3.0 synopsis:            A fold function for Bool description:         The `bool' function allows folding over boolean values.                      .@@ -26,6 +26,7 @@                      Tom Lokhorst,                      Sebastiaan Visser maintainer:          Tom Lokhorst <tom@lokhorst.eu>+homepage:            http://tom.lokhorst.eu/bool-extras stability:           Stable category:            Data build-type:          Simple@@ -33,5 +34,5 @@ extra-source-files:  examples/*.hs hs-source-dirs:      src exposed-modules:     Data.Bool.Extras-build-depends:       base+build-depends:       base >= 3 && < 5 
src/Data/Bool/Extras.hs view
@@ -9,6 +9,7 @@    -- * Other functions   , mwhen+  , mwhenM   , whenA   , whenC   , whenM@@ -33,6 +34,7 @@ --  -- Comparable to the `maybe' or `either' functions for their respective data -- types.+{-# INLINE bool #-} bool :: a -> a -> Bool -> a bool x _ False = x bool _ y True  = y@@ -47,30 +49,37 @@ mwhen :: (Monoid a) => a -> Bool -> a mwhen = bool mempty +-- | Boolean operation for monads, with a monoid default.+-- +-- Return its first argument when applied to `True',+-- returns `return mempty' when applied to `False'.+mwhenM :: (Monad m, Monoid a) => m a -> Bool -> m a+mwhenM = bool (return mempty)+ -- | Boolean operation for arrows. --  -- Returns its first argument when applied to `True', -- returns `returnA' when applied to `False'.-whenA :: Arrow a => a b b -> Bool -> a b b+whenA :: (Arrow a) => a b b -> Bool -> a b b whenA = bool returnA  -- | Boolean operation for categories. --  -- Returns its first argument when applied to `True', -- returns @Control.Category.@`Cat.id' when applied to `False'.-whenC :: Category cat => cat b b -> Bool -> cat b b+whenC :: (Category cat) => cat a a -> Bool -> cat a a whenC = bool Cat.id  -- | Boolean operation for monads. --  -- Returns its first argument when applied to `True',--- returns @Control.Category.@`Cat.id' when applied to `False'.+-- returns `return' when applied to `False'. -- -- @Control.Monad.@`when' can be expressed in terms of `whenM', like so: --  -- > when :: Monad m => Bool -> m () -> m () -- > when b m = (const m `whenM` b) ()-whenM :: Monad m => (b -> m b) -> Bool -> (b -> m b)+whenM :: (Monad m) => (a -> m a) -> Bool -> (a -> m a) whenM = bool return -- Alternative implementation using Kleisli arrows: -- whenM m = runKleisli . whenC (Kleisli m)@@ -78,10 +87,10 @@ {- -- Functions that are also possible, but we haven't found an explicit need for -whenP :: MonadPlus m => a -> Bool -> m a+whenP :: (MonadPlus m) => a -> Bool -> m a whenP = bool mzero . return -(<?>) :: Applicative f => (a -> f a) -> Bool -> (a -> f a)+(<?>) :: (Applicative f) => (a -> f a) -> Bool -> (a -> f a) (<?>) = bool pure -}