& package:relude

& 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 $. This is a version of flip id, where id is specialized from a -> a to (a -> b) -> (a -> b) which by the associativity of (->) is (a -> b) -> a -> b. flipping this yields a -> (a -> b) -> b which is the type signature of &

Examples

>>> 5 & (+1) & show
"6"
>>> sqrt $ [1 / n^2 | n <- [1..1000]] & sum & (*6)
3.1406380562059946
@since base-4.8.0.0
Monadic version of (&&) operator. It is lazy by the second argument (similar to (||)), meaning that if the first argument is False, the function will return False without evaluating the second argument.
>>> Just False &&^ Just True
Just False

>>> Just True &&^ Just True
Just True

>>> Just True &&^ Nothing
Nothing

>>> Just False &&^ Nothing
Just False

>>> Just False &&^ error "Shouldn't be evaluated"
Just False
Boolean "and", lazy in the second argument
Fanout: send the input to both argument arrows and combine their output. The default definition may be overridden with a more efficient version if desired.
Flipped version of <$>.
(<&>) = flip fmap
@since base-4.11.0.0

Examples

Apply (+1) to a list, a Just and a Right:
>>> Just 2 <&> (+1)
Just 3
>>> [1,2,3] <&> (+1)
[2,3,4]
>>> Right 3 <&> (+1)
Right 4