when package:base-compat

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.
applyWhen applies a function to a value if a condition is true, otherwise, it returns the value unchanged. It is equivalent to flip (bool id). Algebraic properties: