Well I guess you do not know how to read the types correctly.
c01
's type is (A -> B -> C) -> (B -> A -> C)
. That means it is a function, which takes a function as argument and returns a function.
It takes "a function with two arguments" (I mean in the Haskell sense of "a function with two arguments", not in the Scala or Java sense), of type A
and B
, which returns a value of type C
.
It must return a function with two arguments, of type A
and B
(but in the other order), which returns a value of type C
.
So what must this function, c01
, do?
It must take a function, and turn it into the same function with the order of its arguments reversed.
So:
fun f => fun b => fun a => f a b
Or equivalently (just adding some parentheses to make it clearer):
fun f => (fun b => fun a => f a b)