-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A fold function for Bool -- -- The bool function allows folding over boolean values. -- -- This is comparable to the maybe or either functions on -- their respective types. -- -- The bool function is a replacement for the build-in if then -- else-syntax. However, since it is a function, it can be partially -- applied and passed around to higher order functions, like so: -- --
-- ghci> :m + Data.Bool.Extras -- ghci> let yesOrNo = bool "no" "yes" -- ghci> map yesOrNo [True, False, True] -- ["yes", "no", "yes"] ---- -- Note that the arguments to bool are in the opposite order of -- the if then else-syntax; First the false value, then the true -- value, and finally the boolean. @package bool-extras @version 0.3.0 -- | This module provides some convenient functions for dealing with -- Booleans. -- -- The most important one being bool, a function that can be used -- in place of the build-in if then else-syntax. module Data.Bool.Extras -- | Defines the fold over a boolean value. -- -- Returns its first argument when applied to False, returns its -- second argument when applied to True. -- -- Comparable to the maybe or either functions for their -- respective data types. bool :: a -> a -> Bool -> a -- | Boolean operation for monoids. -- -- Returns its first argument when applied to True, returns -- mempty when applied to False. mwhen :: Monoid a => a -> Bool -> a -- | 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 -- | 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 -- | Boolean operation for categories. -- -- Returns its first argument when applied to True, returns -- Control.Category.id when applied to False. whenC :: Category cat => cat a a -> Bool -> cat a a -- | Boolean operation for monads. -- -- Returns its first argument when applied to True, 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 => (a -> m a) -> Bool -> (a -> m a) -- | Algebra for Bool data type. -- -- The first field of the pair represents the False value, the -- second field represents the True value. type BoolAlgebra r = (r, r) -- | Catamorphism for booleans. cata :: BoolAlgebra r -> Bool -> r -- | Anamorphism for booleans. ana :: (b -> Bool) -> b -> Bool