control-bool-0.2.1: Useful combinators for boolean expressions

Copyright(C) 2013 Fumiaki Kinoshita
LicenseBSD-style (see the file LICENSE)
MaintainerFumiaki Kinoshita <fumiexcel@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Control.Bool

Contents

Description

Useful combinators for boolean expressions

Synopsis

A pure combinator

bool :: a -> a -> Bool -> a #

bool a b is a function that returns a if the argument is True, otherwise returns b.

ifThenElse :: Bool -> a -> a -> a #

An argument-permuted equivalent of bool.

Applicative combinators

notF :: Functor f => f Bool -> f Bool #

A lifted not.

(<||>) :: Applicative f => f Bool -> f Bool -> f Bool infixr 2 #

A lifted (||).

(<&&>) :: Applicative f => f Bool -> f Bool -> f Bool infixr 3 #

A lifted (&&).

aguard :: Alternative m => Bool -> m () #

An Alternative analogue of guard.

aguard' :: Alternative m => Bool -> a -> m a #

aguard' b returns the second argument if b is True, otherwise becomes empty.

Monadic combinators

notM :: Monad m => m Bool -> m Bool #

A lifted not.

(<|=>) :: Monad m => m Bool -> m Bool -> m Bool infixr 2 #

A lifted (||), but short-circuited.

(<&=>) :: Monad m => m Bool -> m Bool -> m Bool infixr 3 #

A lifted (&&), but short-circuited.

guard' :: MonadPlus m => Bool -> a -> m a #

guard' b a returns a if b is True, otherwise becomes mzero.

guardM' :: MonadPlus m => m Bool -> a -> m a #

guard' b returns the second argument if b is True, otherwise becomes mzero.

whenM :: (Monoid a, Monad m) => m Bool -> m a -> m a #

Run the action if the given monadic condition becomes True.

unlessM :: (Monoid a, Monad m) => m Bool -> m a -> m a #

Run the action if the given monadic condition becomes False.

ifThenElseM :: Monad m => m Bool -> m a -> m a -> m a #