Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *Main> :t (.)
- (.) :: (b -> c) -> (a -> b) -> a -> c
- Write as prefix instead of infix
- (.) . (.) <=> (.) (.) (.)
- ^ ^
- In the same way as
- 1 + 2 <=> (+) 1 2
- Now, rename the types in the second and third (.)
- For example:
- For the second (.):
- (.) :: (x2 -> x3) -> (x1 -> x2) -> x1 -> x3
- And the third (.):
- (.) :: (y2 -> y3) -> (y1 -> y2) -> y1 -> y3
- Now, the first argument (b -> c) of the first (.) is given the second (.). This means that:
- (b -> c) = (x2 -> x3) -> (x1 -> x2) -> x1 -> x3
- and therefore
- b: (x2 -> x3)
- c: (x1 -> x2) -> x1 -> x3
- And now the same for the second argument (a -> b) that's given the third (.):
- (a -> b) = (y2 -> y3) -> (y1 -> y2) -> y1 -> y3
- and therefore:
- a: (y2 -> y3)
- b: (y1 -> y2) -> y1 -> y3
- Solving the type of b:
- (x2 -> x3) = (y1 -> y2) -> y1 -> y3
- therefore:
- x2 = (y1 -> y2)
- x3 = y1 -> y3
- Knowing this, we can obtain the type of c:
- c = (x1 -> x2) -> x1 -> x3
- = (x1 -> y1 -> y2) -> x1 -> y1 -> y3
- And a:
- a = (y2 -> y3)
- Going back to our whole expression:
- (.).(.) = (.) (.) (.) :: a -> c
- = (y2 -> y3) -> (x1 -> y1 -> y2) -> x1 -> y1 -> y3
- And we can rename the types as in the solutions:
- (b -> c) -> (a1 -> a -> b) -> a1 -> a -> c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement