I'm having trouble with understanding how function application works with currying in haskell. If I have following function:
($) :: (a -> b) -> a -> b
I understand that to partially apply this function I need to provide (a -> b)
function ($
's first argument).
Why then is it possible to apply a value first (i.e. reverse arguments)?
($ 0) :: Num a => (a -> b) -> b
What am I missing here?
($)
is an operator. In Haskell, any operator can be written in a left-section (like(x $)
) or a right-section (like($ x)
):Note that the only exception to this rule is
(-)
, in order to conveniently write negative numbers:In case you want to tersely write
(\y -> y - x)
, you can usesubtract
: