Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. (t -> (f1 t, f2 t, f3 t))
  2.  
  3. (f1,f2,f3 -> (t -> (f1 t, f2 t, f3 t)))
  4.  
  5. (f1,f2,f3,t -> (f1 t, f2 t, f3 t))
  6.  
  7. f x = (f1 x, f2 x, f3 x)
  8. f f1 f2 f3 x = (f1 x, f2 x, f3 x)
  9.  
  10. (t -> (f1 t, f2 t, f3 t))
  11.  
  12. liftM (,,) f1 `ap` f2 `ap` f3
  13.  
  14. (,,) <$> f1 <*> f2 <*> f3
  15.  
  16. (f1 f2 f3 -> (t -> (f1 t, f2 t, f3 t)))
  17.  
  18. f1 f2 f3 -> (,,) <$> f1 <*> f2 <*> f3
  19. = f1 f2 -> ((,,) <$> f1 <*> f2 <*>)
  20. = f1 f2 -> (<*>) ((,,) <$> f1 <*> f2)
  21. = f1 f2 -> ((<*>) . ((,,) <$> f1 <*>)) f2
  22. = f1 -> (<*>) . ((,,) <$> f1 <*>)
  23. = f1 -> (<*>) . (<*>) ((,,) <$> f1)
  24. = f1 -> (((<*>) .) . (<*>) . (<$>) (,,)) f1
  25. = ((<*>) .) . (<*>) . (<$>) (,,)
  26.  
  27. uncurry (uncurry (,,)) . ((f &&& g) &&& h)
  28.  
  29. arrowized :: Arrow cat => cat a a1 -> cat a b1 -> cat a b -> cat a (a1, b1, b)
  30. arrowized f g h => arr (uncurry (uncurry (,,))) . ((f &&& g) &&& h)
  31.  
  32. x -> (f x, g x, h x)
  33.  
  34. ap (liftM2 (,,) f g) h
  35.  
  36. f1 f2 f3 t -> (,,) (f1 t) (f2 t) (f3 t)
  37.  
  38. instance Applicative ((->) a) where -- (a ->) is meant here
  39. pure = const
  40. (<*>) f g x = f x (g x)
  41.  
  42. liftA3 f a b c = f <$> a <*> b <*> c
  43.  
  44. Prelude Control.Applicative> :t liftA3 (,,)
  45. liftA3 (,,) :: (Applicative f) => f a -> f b -> f c -> f (a, b, c)
  46.  
  47. liftA3 (,,) ~ (t->a) -> (t->b) -> (t->c) -> (t->(a,b,c))
  48.  
  49. liftA3 (,,) f g h t = ((((,,) <$> f) <*> g) <*> h) t
  50. = (((,,) <$> f) <*> g) t (h t)
  51. = (((,,) <$> f) t (g t) (h t)
  52.  
  53. = (((,,) . f) t (g t) (h t)
  54. = (,,) (f t) (g t) (h t)
  55. = (f t, g t, h t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement