In Haskell, all functions take one argument. Also, operators are functions.
First, the one argument thing is known as currying. With higher-order functions, returning a function is admissible, so
map :: (a -> b) -> [a] -> [b]
can also be thought of as:
map :: (a -> b) -> ([a] -> [b])
like so:
ghci> :t map length
map length :: [[a]] -> [Int]
As for operators being functions, function names that are alphanumeric default to prefix (e.g. f 10) while those that are symbolic default to infix (e.g. 10 + 18). To use an alphanumeric name in infix, use backticks, e.g.:
ghci> 5 `max` 6
6
Use parentheses to prefix an "operator"-style name, like so:
ghci> (+) 5 6
11
The (+1) that you're meeting is an additional bit of syntactic sugar. It's identical to (\x -> x + 1). It allows you to do things like this:
First, the one argument thing is known as currying. With higher-order functions, returning a function is admissible, so
can also be thought of as: like so: As for operators being functions, function names that are alphanumeric default to prefix (e.g. f 10) while those that are symbolic default to infix (e.g. 10 + 18). To use an alphanumeric name in infix, use backticks, e.g.: Use parentheses to prefix an "operator"-style name, like so: The (+1) that you're meeting is an additional bit of syntactic sugar. It's identical to (\x -> x + 1). It allows you to do things like this: