lalala33rfs

Untitled

Nov 19th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. newtype Cmps f g x = Cmps { getCmps :: f (g x) } deriving (Eq,Show)
  2.  
  3. instance (Functor f, Functor g) => Functor (Cmps f g) where
  4. fmap f (Cmps x) = Cmps (fmap (fmap f) x)
  5.  
  6. instance (Applicative f, Applicative g) => Applicative (Cmps f g) where
  7. pure x = Cmps (pure (pure x))
  8. Cmps f <*> Cmps x = Cmps ((<*>) ((<$>) (<*>) f) x)
  9.  
  10. instance (Foldable f, Foldable g) => Foldable (Cmps f g) where
  11. foldMap f (Cmps t) = foldMap (foldMap f) t
Add Comment
Please, Sign In to add comment