Currying is something like this:
addTwoNumbers
is a function that takes a number and returns a function that takes a number that returns a number.
So addTwoNumbers 5
is in fact a function that takes a number and returns a number, which is how currying works. Since you assign addTwoNumbers 5
to add5ToNumber
, that make add5ToNumber
a function that takes a number an returns a number.
I don't know what type definition looks like in F# but in Haskell, the type definition of functions makes this clear:
addTwoNumbers :: (Num a) => a -> a -> a
On the other hand, if you wrote addTwonumbers
to take a two tuple,
addTwoNumbers :: (Num a) => (a, a) -> a
then is would be a function that takes a two tuple and returns a number, so add5ToNumber
would not be able to be created as you have it.