3 ms·
I think i also got confused the first time i saw that syntax (being used to C-like languages hehe). It started making lots of sense once i got familiar with the
by epidemian 13y ago
I think i also got confused the first time i saw that syntax (being used to C-like languages hehe). It started making lots of sense once i got familiar with the concept of currying and functions as first-class values.
Suppose you have a function f with type Int -> Int -> Int (you can read it as "it takes two integers and returns an integer" or "it takes one integer and returns a function that takes an integer and returns an integer"), then:
f
is the function itself, and it is a usable value.
f 42
is a function of type Int -> Int, and a perfectly valid value too. And
f 42 33
is just and Int.
It's like with each application you take one arrow from the function type; until you get something that's not a function any more :)