Question: In Haskell, I can't understand this sentence, (a -> b -> c) -> (b -> a -> c) is the same as (a -> b
In Haskell,
I can't understand this sentence, (a -> b -> c) -> (b -> a -> c) is the same as (a -> b -> c) -> (b -> (a -> c))
Why (a -> b -> c) -> (b -> a -> c) is the same as (a -> b -> c) -> (b -> (a -> c)) ?
Could you explain it with specific examples?

flip' :: (a -> b -> c) -> (b -> a -> c) flip' f = g where g xy - fyx Reading the type declaration, we say that it takes a function that takes an a and a b and returns a function that takes a b and an a. But because functions are curried by default, the second pair of parentheses is really unnecessary, because -> is right associative by default. (a -> b -> c) -> (b -> a -> c) is the same as (a -> b -> c) -> (b-> (a -> c)), which is the same as (a -> b -> c) -> b -> a -> c. We wrote that g x y = f y x. If that's true, then fy x = g x y must also hold, right? Keeping that in mind, we can define this function in an even simpler manner
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
