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?

In Haskell, I can't understand this sentence, (a -> b -> c)

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!