All of the examples I've seen so far create a "wrapper" function around Basics.+
and then partially apply that:
sum x y =
x + y
plusOne =
sum 1
However, I'm sure that there's a way to avoid the extra wrapping.
Wrap it in parenthesis
plusOne =
(+) 1
(+ 1)
like in Haskell ? And why (-) 1
have a very curious behavior... but (+) -1
works has intended :-)
Commented
Dec 15, 2015 at 13:45
(+ 1)
is how you would partially apply a regular function but for infix you have to wrap it in ()
to make it behave like a regular function first. (-)
has the signature number -> number -> number
. It subtracts the second number from the first number. (-) 1
partially applies 1 as the first number, so it is the same as f x = 1 - x
. If you want it the other way you can use the flip function flip (-) 1
Commented
Dec 15, 2015 at 15:18