{-# OPTIONS_HADDOCK show-extensions #-}
module IsomorphismClass.Isomorphism
( Isomorphism,
iso,
)
where
import Control.Applicative (pure)
import Control.Arrow (Kleisli (Kleisli))
import Control.Category ((.))
import Control.Comonad (Cokleisli (Cokleisli), Comonad, extract)
import Control.Monad (Monad)
import GHC.Base (Type)
import IsomorphismClass (IsomorphicTo, from, to)
import Prelude (($))
class Isomorphism (c :: Type -> Type -> Type) where
iso :: IsomorphicTo a b => c a b
instance Isomorphism (->) where
iso :: IsomorphicTo a b => a -> b
iso :: forall a b. IsomorphicTo a b => a -> b
iso = forall a b. IsomorphicTo b a => a -> b
from
instance Monad m => Isomorphism (Kleisli m) where
iso :: IsomorphicTo a b => Kleisli m a b
iso :: forall a b. IsomorphicTo a b => Kleisli m a b
iso = forall (m :: * -> *) a b. (a -> m b) -> Kleisli m a b
Kleisli forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall a b. IsomorphicTo a b => b -> a
to
instance Comonad w => Isomorphism (Cokleisli w) where
iso :: IsomorphicTo a b => Cokleisli w a b
iso :: forall a b. IsomorphicTo a b => Cokleisli w a b
iso = forall {k} (w :: k -> *) (a :: k) b. (w a -> b) -> Cokleisli w a b
Cokleisli forall a b. (a -> b) -> a -> b
$ forall a b. IsomorphicTo a b => b -> a
to forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. forall (w :: * -> *) a. Comonad w => w a -> a
extract