In Haskell, all functions are considered curried: that is, all functions in Haskell take just one argument.
Let's take the function div
:
div :: Int -> Int -> Int
If we call this function with 6 and 2 we unsurprisingly get 3:
Prelude> div 6 2 3
However, this doesn't quite behave in the way we might think. First div 6
is evaluated and returns a function of type Int -> Int
. This resulting function is then applied to the value 2 which yields 3.
When we look at the type signature of a function, we can shift our thinking from "takes two arguments of type Int
" to "takes one Int
and returns a function that takes an Int
". This is reaffirmed if we consider that arrows in the type notation associate to the right, so div
can in fact be read thus:
div :: Int -> (Int -> Int)
In general, most programmers can ignore this behaviour at least while they're learning the language. From a theoretical point of view, "formal proofs are easier when all functions are treated uniformly (one argument in, one result out)."