Created
February 21, 2022 15:44
-
-
Save kakkun61/f1bd3c7fabbb5f1baa30de111fcae97a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FunctorB b where | |
bmap :: forall f g. (Functor f, Functor g) => (forall a. f a -> g a) -> b f -> b g | |
instance {-# OVERLAPPABLE #-} (FunctorT (Flip t), FunctorB a) => FunctorB (t a) where | |
bmap f a = runFlip $ tmap f $ Flip a | |
instance (FunctorT t, FunctorB a) => FunctorB (Flip t a) where | |
bmap f a = Flip $ tmap f $ runFlip a | |
class FunctorT t where | |
tmap :: forall f g x. (Functor f, Functor g, FunctorB x) => (forall a. f a -> g a) -> t f x -> t g x | |
default tmap :: forall f g x. (Functor f, Functor g, FunctorB x) => (forall a. f a -> g a) -> t f x -> t g x | |
tmap f a = runFlip $ bmap f $ Flip a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment