unless -package:shelly
The reverse of
when.
Examples
>>> do x <- getLine
unless (x == "hi") (putStrLn "hi!")
comingupwithexamplesisdifficult
hi!
>>> unless (pi > exp 1) Nothing
Just ()
base-compat Control.Monad.Compat,
protolude Protolude.Monad,
rio RIO.Prelude,
base-prelude BasePrelude,
turtle Turtle,
classy-prelude ClassyPrelude,
Cabal-syntax Distribution.Compat.Prelude,
ihaskell IHaskellPrelude,
basement Basement.Compat.Base Basement.Imports,
base-compat-batteries Control.Monad.Compat,
rebase Rebase.Prelude,
persistent-test Init,
massiv-test Test.Massiv.Utils,
incipit-base Incipit.Base,
LambdaHack Game.LambdaHack.Core.Prelude,
cabal-install-solver Distribution.Solver.Compat.Prelude,
faktory Faktory.Prelude,
can-i-haz Control.Monad.Except.CoHas Control.Monad.Reader.Has,
yesod-paginator Yesod.Paginator.Prelude,
control-monad-free Control.Monad.Free,
distribution-opensuse OpenSuse.Prelude When the given predicate is false for the input signal.
- Depends: now.
- Inhibits: unless the predicate is false.
Show a custom type error if p is false (or stuck).
if condition met, fail without a message; better avoided, since AI
can't value it well
Like
unless, but where the test can be monadic.
Monadic version of unless, taking the condition in the monad
Do nothing on `--expert`, otherwise run the given action.
Monadic version of
unless. Reverse of
whenM.
Conditionally don't execute the provided action.
>>> unlessM (pure False) $ putTextLn "No text :("
No text :(
>>> unlessM (pure True) $ putTextLn "Yes text :)"
Run the second value if the first value returns
False
Only perform the action if the predicate returns
False.
Since 0.9.2
Display something only if the condition is
False (empty string
otherwise).
A variant of
unless with a monadic predicate.