lalala33rfs

Untitled

Nov 19th, 2019
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. data Triple a = Tr a a a deriving (Eq,Show)
  2.  
  3. instance Functor Triple where
  4. fmap f (Tr x y z) = Tr (f x) (f y) (f z)
  5.  
  6. instance Applicative Triple where
  7. pure f = Tr f f f
  8. (<*>) (Tr fx fy fz) (Tr x y z) = (Tr (fx x) (fy y) (fz z))
  9.  
  10. instance Foldable Triple where
  11. foldr ff ini (Tr a b c) = ff a (ff b (ff c ini))
  12.  
  13. instance Traversable Triple where
  14. --traverse :: (a -> f b) -> t a -> f (t b)
  15. traverse g (Tr a b c) = Tr <$> g a <*> g b <*> g c
Advertisement
Add Comment
Please, Sign In to add comment