when is:exact

Conditional execution of Applicative expressions. For example,

Examples

when debug (putStrLn "Debugging")
will output the string Debugging if the Boolean value debug is True, and otherwise do nothing.
>>> putStr "pi:" >> when False (print 3.14159)
pi:
Conditional execution of Applicative expressions. For example,
when debug (putStrLn "Debugging")
will output the string Debugging if the Boolean value debug is True, and otherwise do nothing.
\b m -> when b m == mfilter (const b) (m::Maybe Ordering)
\b m -> when b m == mfilter (const b) (m::String)
f `when` g : when the predicate g holds, f is applied, else the identity filter this
Interior editing: f when g applies f only when the predicate g succeeds, otherwise the content is unchanged.
Generalization of when
When the given predicate is true for the input signal.
  • Depends: now.
  • Inhibits: when the predicate is false.
The given pattern transformation is applied only when the given test function returns True. The test function will be called with the current cycle as a number.
d1 $ when (elem '4' . show)
(striate 4)
$ sound "hh hc"
The above will only apply striate 4 to the pattern if the current cycle number contains the number 4. So the fourth cycle will be striated and the fourteenth and so on. Expect lots of striates after cycle number 399.
Generalization of when.
An kind of if-then-else statement. Because of monotonicity requirements, this should be sufficient.
RS.get (RS.when b r) === (if RB.get b then RS.get r else S.empty)