Advertisement
Guest User

Untitled

a guest
May 26th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. *Main> :t (.)
  2. (.) :: (b -> c) -> (a -> b) -> a -> c
  3.  
  4. Write as prefix instead of infix
  5.  
  6. (.) . (.) <=> (.) (.) (.)
  7. ^ ^
  8.  
  9. In the same way as
  10. 1 + 2 <=> (+) 1 2
  11.  
  12. Now, rename the types in the second and third (.)
  13. For example:
  14. For the second (.):
  15. (.) :: (x2 -> x3) -> (x1 -> x2) -> x1 -> x3
  16. And the third (.):
  17. (.) :: (y2 -> y3) -> (y1 -> y2) -> y1 -> y3
  18.  
  19. Now, the first argument (b -> c) of the first (.) is given the second (.). This means that:
  20. (b -> c) = (x2 -> x3) -> (x1 -> x2) -> x1 -> x3
  21. and therefore
  22. b: (x2 -> x3)
  23. c: (x1 -> x2) -> x1 -> x3
  24.  
  25. And now the same for the second argument (a -> b) that's given the third (.):
  26. (a -> b) = (y2 -> y3) -> (y1 -> y2) -> y1 -> y3
  27. and therefore:
  28. a: (y2 -> y3)
  29. b: (y1 -> y2) -> y1 -> y3
  30.  
  31. Solving the type of b:
  32. (x2 -> x3) = (y1 -> y2) -> y1 -> y3
  33. therefore:
  34. x2 = (y1 -> y2)
  35. x3 = y1 -> y3
  36.  
  37. Knowing this, we can obtain the type of c:
  38. c = (x1 -> x2) -> x1 -> x3
  39. = (x1 -> y1 -> y2) -> x1 -> y1 -> y3
  40.  
  41. And a:
  42. a = (y2 -> y3)
  43.  
  44. Going back to our whole expression:
  45. (.).(.) = (.) (.) (.) :: a -> c
  46. = (y2 -> y3) -> (x1 -> y1 -> y2) -> x1 -> y1 -> y3
  47.  
  48. And we can rename the types as in the solutions:
  49. (b -> c) -> (a1 -> a -> b) -> a1 -> a -> c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement