In Haskell all functions are originally curried, right?
So, let's look at the max
function, and I'll write what I understand about how this works.
When I write something like this:
max 4 5
What happens is that a new funcion is created that internally has value of 4, which then recieves a value, so this function is applied to 5 and a correct value is returned?
Did I say something wrong somehow or is this correct?
That's correct. You can remember what currying is all about by memorizing two of its most important identities:
-- Function type right-associativity:
a -> b -> c = a -> (b -> c)
-- Function application left-associativity:
f x y = (f x) y
These two identities work together and produce a curried language.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.