-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Basic conditional operators with monadic variants. -- -- A very simple library implementing various conditional operations, as -- well as some functions for dealing with conditions in monadic code. -- Feel free to send ideas and suggestions for new conditional operators -- to the maintainer. @package cond @version 0.0 -- | A convenient set of useful conditional operators. module Control.Cond -- | A simple conditional function. if' :: Bool -> a -> a -> a -- | if' with the Bool argument at the end (infixr 1). (??) :: a -> a -> Bool -> a -- | A catamorphism for the Bool type. This is analogous to foldr, maybe, -- and either. The first argument is the false case, the second argument -- is the true case, and the last argument is the predicate value. bool :: a -> a -> Bool -> a -- | Composes a predicate function and 2 functions into a single function. -- The first function is called when the predicate yields True, the -- second when the predicate yields False. select :: (a -> Bool) -> (a -> b) -> (a -> b) -> (a -> b) -- | Lisp-style conditionals. If no conditions match, then a runtime -- exception is thrown. Here's a trivial example: -- --
--   signum x = cond [(x > 0     , 1 )
--                   ,(x < 0     , -1)
--                   ,(otherwise , 0 )]
--   
cond :: [(Bool, a)] -> a -- | Lisp-style conditionals generalized over MonadPlus. If no -- conditions match, then the result is mzero. This is a safer -- variant of cond. condPlus :: MonadPlus m => [(Bool, a)] -> m a -- | if' lifted to Monad. Unlike liftM3 if', -- this is short-circuiting in the monad, such that only the predicate -- action and one of the remaining argument actions are executed. ifM :: Monad m => m Bool -> m a -> m a -> m a -- | Lifted boolean or. Unlike liftM2 (||), This function -- is short-circuiting in the monad. Fixity is the same as || -- (infixr 2). (<||>) :: Monad m => m Bool -> m Bool -> m Bool -- | Lifted boolean and. Unlike liftM2 (&&), this -- function is short-circuiting in the monad. Fixity is the same as -- && (infxr 3). (<&&>) :: Monad m => m Bool -> m Bool -> m Bool -- | cond lifted to Monad. If no conditions match, a runtime -- exception is thrown. condM :: Monad m => [(m Bool, m a)] -> m a -- | condPlus lifted to Monad. If no conditions match, then -- mzero is returned. condPlusM :: MonadPlus m => [(m Bool, m a)] -> m a