I have a question regarding two types int -> (int -> int) and (int -> int) -> int. What is the difference between these two?
I read here somewhere that the first one could be interpreted as a function that that takes an int and returns a function that takes and int and returns an int, which is the same as int ->int -> int. Is this right?
The difference between
int -> (int -> int)andint -> int -> intis negligible (you would really only care if you had to interop with another language). These are curried functions which effectively take two integers and return an integer (for example, the built-in addition operator has a type along these lines).However, both of these are very different from
(int -> int) -> int, which takes a function from integers to integers and returns an integer. As others have mentioned, the only simple example of such a function would apply the given function to a specific value (e.g.fun (f:int->int) -> f 13).