universum-0.4: Custom prelude used in Serokell

Safe HaskellSafe
LanguageHaskell2010

Bool

Description

Convenient commonly used and very helpful functions to work with Bool.

Synopsis

Documentation

whenM :: Monad m => m Bool -> m () -> m () Source #

Monadic version of when.

>>> whenM (pure False) $ putText "No text :("
>>> whenM (pure True)  $ putText "Yes text :)"
Yes text :)
>>> whenM (Just True) (pure ())
Just ()
>>> whenM (Just False) (pure ())
Just ()
>>> whenM Nothing (pure ())
Nothing

unlessM :: Monad m => m Bool -> m () -> m () Source #

Monadic version of unless.

>>> unlessM (pure False) $ putText "No text :("
No text :(
>>> unlessM (pure True) $ putText "Yes text :)"

ifM :: Monad m => m Bool -> m a -> m a -> m a Source #

Monadic version of if-then-else.

>>> ifM (pure True) (putText "True text") (putText "False text")
True text

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

Reversed version of if-then-else.

>>> bool 5 10 True
10
>>> bool 5 10 False
5