Skip to content

Instantly share code, notes, and snippets.

@phadej
Created June 30, 2021 23:02
Show Gist options
  • Select an option

  • Save phadej/16f97f32fbbc40e8374fd38f4f115c7a to your computer and use it in GitHub Desktop.

Select an option

Save phadej/16f97f32fbbc40e8374fd38f4f115c7a to your computer and use it in GitHub Desktop.
data Mokhov2 f g a where
Mokhov2 :: (x -> Either a (y -> a)) -> f x -> g y -> Mokhov2 f g a
toMokhov2 :: Mokhov f g a -> Mokhov2 f g a
toMokhov2 (x :<*?: y) = Mokhov2 f y x where
f :: (x -> a) -> Either a (Either x a -> a)
f xa = Right $ either xa id
fromMokhov2 :: (Functor f, Functor g) => Mokhov2 f g a -> Mokhov f g a
fromMokhov2 (Mokhov2 f x y) =
fmap Left y
:<*?:
fmap (\x' y' -> either id ($ y') (f x')) x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment