The trick in understanding this is that all haskell functions accept only a maximum of 1 argument, simply that the implicit brackets in the type signature and syntax sake make it look like there are more arguments. To use ++ as an example, the following conversions are equivalent
xs ++ ys = ... (++) xs ys = ... (++) xs = \ys -> ... (++) = \xs -> (\ys -> ...) (++) = \xs ys -> ...
Another quick example:
doubleList :: [Int] -> [Int] doubleList = map (*2)
Here we have a single argument function doubleList without any explicit arguments. That would be equivalent to writing
doubleList x = map (*2) x
Or any of the following
doubleList = \x -> map (*2) x doubleList = \x -> map (\y -> y * 2) x doubleList x = map (\y -> y * 2) x doubleList = map (\y -> y * 2)
The first definition of doubleList is written in the so-called point notation, the so-called, because in the mathematical theory that supports it, arguments are called "points", therefore without points - "without arguments" ,.
More complex example:
func = \xyz -> x * y + z func = \x -> \yz -> x * y + z func x = \yz -> x * y + z func x = \y -> \z -> x * y + z func xy = \z -> x * y + z func xyz = x * y + z
Now, if we want to completely remove all references to arguments, we can use the operator . which performs the composition function:
func xyz = (+) (x * y) z -- Make the + prefix func xy = (+) (x * y) -- Now z becomes implicit func xy = (+) ((*) xy) -- Make the * prefix func xy = ((+) . ((*) x)) y -- Rewrite using composition func x = (+) . ((*) x) -- Now y becomes implicit func x = (.) (+) ((*) x) -- Make the . prefix func x = ((.) (+)) ((*) x) -- Make implicit parens explicit func x = (((.) (+)) . (*)) x -- Rewrite using composition func = ((.) (+)) . (*) -- Now x becomes implicit func = (.) ((.) (+)) (*) -- Make the . prefix
So, you can see that there are many ways to write a certain function with a different number of explicit “arguments”, some of which are very readable (ie func xyz = x * y + z ), and some are just a mess of characters with a small value (i.e. func = (.) ((.) (+)) (*) )