Data.Function.Compat
module Data.Function
(&) :: a -> (a -> b) -> b infixl 1 #
& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.
&
$
>>> 5 & (+1) & show "6"
>>>
5 & (+1) & show
Since: base-4.8.0.0
applyWhen :: Bool -> (a -> a) -> a -> a #
applyWhen applies a function to a value if a condition is true, otherwise, it returns the value unchanged.
applyWhen
It is equivalent to flip (bool id).
flip (bool id)
flip
bool
id
Algebraic properties:
applyWhen True = id
True
applyWhen False f = id
False
Since: base-4.18.0.0