($)
is an operator. In Haskell, any operator can be written in a left-section (like (x $)
) or a right-section (like ($ x)
):
(x $) = (\y -> x $ y) = ($) x
($ x) = (\y -> y $ x) = flip ($) x
Note that the only exception to this rule is (-)
, in order to conveniently write negative numbers:
\x -> (x-) :: Num a => a -> a -> a -- equivalent to \x -> (-) x
\x -> (-x) :: Num a => a -> a -- equivalent to \x -> negate x
In case you want to tersely write (\y -> y - x)
, you can use subtract
:
\x -> subtract x :: Num a => a -> a -> a -- equivalent to \x -> flip (-) x