when

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)
Show a custom type error if p is true.
if condition not met, fail without a message; better avoided, since AI can't value it well
Performs an IO action after the last failure of a property.
Performs an IO action every time a property fails. Thus, if shrinking is done, this can be used to keep track of the failures along the way.
Execute the given action only when the specified socket option is supported. Any return value is ignored.
A splitting strategy that splits on any elements that satisfy the given predicate.
>>> split (whenElt (<0)) [2,4,-3,6,-9,1 :: Int]
[[2,4],[-3],[6],[-9],[1]]
Returns an unfolding only if (a) not a strong loop breaker and (b) active in according to is_active