unless
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,
shelly Shelly Shelly.Lifted Shelly.Pipe,
classy-prelude ClassyPrelude,
Cabal-syntax Distribution.Compat.Prelude,
universum Universum.Bool.Reexport,
ihaskell IHaskellPrelude,
basement Basement.Compat.Base Basement.Imports,
base-compat-batteries Control.Monad.Compat,
Agda Agda.Utils.Monad,
rebase Rebase.Prelude,
hledger Hledger.Cli.Script,
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,
vcr Imports,
verset Verset,
yesod-paginator Yesod.Paginator.Prelude,
control-monad-free Control.Monad.Free,
distribution-opensuse OpenSuse.Prelude,
hledger-web Hledger.Web.Import,
termonad Termonad.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
Monadic version of unless, taking the condition in the monad
Like
unless, but where the test can be monadic.
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
A monadic-conditional version of the
unless guard.
Only perform the action if the predicate returns
False.
Since 0.9.2
Display something only if the condition is
False (empty string
otherwise).
Monadic version of
unless.
>>> unlessM (pure False) $ putTextLn "No text :("
No text :(
>>> unlessM (pure True) $ putTextLn "Yes text :)"