control-iso-0.1.0.0: A typeclass for type isomorphisms

Control.Isomorphic

Synopsis

Documentation

class Isomorphic b a => Isomorphic a b where Source #

Minimal complete definition

to'

Methods

to' :: a -> b Source #

This type class provides a single method to', which is a bijective function from a to b. We leverage UndecidableSuperClasses to demand that every instance of Isomorphic have an inverse. The sister instance (which may be the same instance) must have the follwing property when used with the to'

    to' . to' = id


Note, this class documents type isomorphisms specifically, where two types are isomorphic to one another. It does not document endoisomorphisms.

Instances

 Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Enum a => Isomorphic Int a Source # Methodsto' :: Int -> a Source # Enum a => Isomorphic a Int Source # Methodsto' :: a -> Int Source # Isomorphic a a Source # Methodsto' :: a -> a Source # Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Isomorphic a (Product a) Source # Methodsto' :: a -> Product a Source # Isomorphic a (Sum a) Source # Methodsto' :: a -> Sum a Source # Isomorphic a (Dual a) Source # Methodsto' :: a -> Dual a Source # Isomorphic a (Identity a) Source # Methodsto' :: a -> Identity a Source # Source # Methodsto' :: IsNothing -> Maybe () Source # Source # Methodsto' :: IsJust -> Maybe () Source # Isomorphic IsLeft (Either () ()) Source # Methodsto' :: IsLeft -> Either () () Source # Isomorphic IsRight (Either () ()) Source # Methodsto' :: IsRight -> Either () () Source # Isomorphic a (Const * a x) Source # Methodsto' :: a -> Const * a x Source # Isomorphic a (D1 * d (C1 * c (S1 * s (K1 * i a))) a) Source # Methodsto' :: a -> D1 * d (C1 * c (S1 * s (K1 * i a))) a Source # Source # Methodsto' :: Maybe () -> IsNothing Source # Source # Methodsto' :: Maybe () -> IsJust Source # Source # Methodsto' :: Fixed a -> Integer Source # Isomorphic (Identity a) a Source # Methodsto' :: Identity a -> a Source # Isomorphic (Dual a) a Source # Methodsto' :: Dual a -> a Source # Isomorphic (Sum a) a Source # Methodsto' :: Sum a -> a Source # Isomorphic (Product a) a Source # Methodsto' :: Product a -> a Source # Isomorphic [a] (ZipList a) Source # Methodsto' :: [a] -> ZipList a Source # Isomorphic (Maybe a) (Last a) Source # Methodsto' :: Maybe a -> Last a Source # Isomorphic (Maybe a) (First a) Source # Methodsto' :: Maybe a -> First a Source # Isomorphic (ZipList a) [a] Source # Methodsto' :: ZipList a -> [a] Source # Isomorphic (First a) (Maybe a) Source # Methodsto' :: First a -> Maybe a Source # Isomorphic (Last a) (Maybe a) Source # Methodsto' :: Last a -> Maybe a Source # Isomorphic (Maybe a) (Either a ()) Source # Methodsto' :: Maybe a -> Either a () Source # Isomorphic (Maybe a) (Either () a) Source # Methodsto' :: Maybe a -> Either () a Source # Isomorphic (m a) (WrappedMonad m a) Source # Methodsto' :: m a -> WrappedMonad m a Source # Isomorphic (NonEmpty a) (a, [a]) Source # Methodsto' :: NonEmpty a -> (a, [a]) Source # Isomorphic (Endo a) (a -> a) Source # Methodsto' :: Endo a -> a -> a Source # Isomorphic (f (g a)) (Compose * * f g a) Source # Methodsto' :: f (g a) -> Compose * * f g a Source # Isomorphic (Either () ()) IsLeft Source # Methodsto' :: Either () () -> IsLeft Source # Isomorphic (Either () ()) IsRight Source # Methodsto' :: Either () () -> IsRight Source # Isomorphic (a -> a) (Endo a) Source # Methodsto' :: (a -> a) -> Endo a Source # Isomorphic (Either () a) (Maybe a) Source # Methodsto' :: Either () a -> Maybe a Source # Isomorphic (Either a ()) (Maybe a) Source # Methodsto' :: Either a () -> Maybe a Source # Isomorphic (a, [a]) (NonEmpty a) Source # Methodsto' :: (a, [a]) -> NonEmpty a Source # Isomorphic (WrappedMonad m a) (m a) Source # Methodsto' :: WrappedMonad m a -> m a Source # Isomorphic ((a, b) -> c) (a -> b -> c) Source # Methodsto' :: ((a, b) -> c) -> a -> b -> c Source # Isomorphic (a -> b -> c) (b -> a -> c) Source # Methodsto' :: (a -> b -> c) -> b -> a -> c Source # Isomorphic (a -> b -> c) ((a, b) -> c) Source # Methodsto' :: (a -> b -> c) -> (a, b) -> c Source # Isomorphic (Either a b) (Either b a) Source # Methodsto' :: Either a b -> Either b a Source # Isomorphic ((a, b), c) (a, (b, c)) Source # Methodsto' :: ((a, b), c) -> (a, (b, c)) Source # Isomorphic (a, (b, c)) ((a, b), c) Source # Methodsto' :: (a, (b, c)) -> ((a, b), c) Source # Isomorphic (a, b) (b, a) Source # Methodsto' :: (a, b) -> (b, a) Source # Isomorphic (a () b) (ArrowMonad a b) Source # Methodsto' :: a () b -> ArrowMonad a b Source # Isomorphic (ST s a) (ST s a) Source # Methodsto' :: ST s a -> ST s a Source # Isomorphic (ST s a) (ST s a) Source # Methodsto' :: ST s a -> ST s a Source # Isomorphic (ArrowMonad a b) (a () b) Source # Methodsto' :: ArrowMonad a b -> a () b Source # Isomorphic (a -> m b) (Kleisli m a b) Source # Methodsto' :: (a -> m b) -> Kleisli m a b Source # Isomorphic ((a, b), c) (a, b, c) Source # Methodsto' :: ((a, b), c) -> (a, b, c) Source # Isomorphic (a, (b, c)) (a, b, c) Source # Methodsto' :: (a, (b, c)) -> (a, b, c) Source # Isomorphic (a b c) (WrappedArrow a b c) Source # Methodsto' :: a b c -> WrappedArrow a b c Source # Isomorphic (Const * a x) a Source # Methodsto' :: Const * a x -> a Source # Isomorphic (a, b, c) ((a, b), c) Source # Methodsto' :: (a, b, c) -> ((a, b), c) Source # Isomorphic (a, b, c) (a, (b, c)) Source # Methodsto' :: (a, b, c) -> (a, (b, c)) Source # Isomorphic (WrappedArrow a b c) (a b c) Source # Methodsto' :: WrappedArrow a b c -> a b c Source # Isomorphic (Kleisli m a b) (a -> m b) Source # Methodsto' :: Kleisli m a b -> a -> m b Source # Isomorphic (D1 * d (C1 * c (S1 * s (K1 * i a))) a) a Source # Methodsto' :: D1 * d (C1 * c (S1 * s (K1 * i a))) a -> a Source # Isomorphic (Compose * * f g a) (f (g a)) Source # Methodsto' :: Compose * * f g a -> f (g a) Source #

via :: forall b a c. (Isomorphic b c, Isomorphic a b) => a -> c Source #

Composition of two bijections

to :: forall b a. Isomorphic a b => a -> b Source #

This is the perfer version of the to' function. The order of arguments in forall has been set up so that the codomain is first. This is important to work with TypeApplications.

     to @Text "hi there"


For call sites where we need to annotate.

from :: forall a b. Isomorphic a b => a -> b Source #

This is the same as to but has the forall arguments with a first.

newtype IsRight Source #

A wrapper for Either () () that decides the isomorphism to Bool is Right biased

Constructors

 IsRight FieldsunIsRight :: Either () ()

Instances

 Source # MethodsshowList :: [IsRight] -> ShowS # Source # Associated Typestype Rep IsRight :: * -> * # Methodsto :: Rep IsRight x -> IsRight # Source # Methods Source # Methods Isomorphic IsRight (Either () ()) Source # Methodsto' :: IsRight -> Either () () Source # Isomorphic (Either () ()) IsRight Source # Methodsto' :: Either () () -> IsRight Source # type Rep IsRight Source # type Rep IsRight = D1 * (MetaData "IsRight" "Control.Isomorphic" "control-iso-0.1.0.0-1BuUlR35Ufz1BYxDUvhzAC" True) (C1 * (MetaCons "IsRight" PrefixI True) (S1 * (MetaSel (Just Symbol "unIsRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Either () ()))))

newtype IsLeft Source #

A wrapper for Either () () that decides the isomorphism to Bool is Left biased

Constructors

 IsLeft FieldsunIsLeft :: Either () ()

Instances

 Source # MethodsshowsPrec :: Int -> IsLeft -> ShowS #showList :: [IsLeft] -> ShowS # Source # Associated Typestype Rep IsLeft :: * -> * # Methodsfrom :: IsLeft -> Rep IsLeft x #to :: Rep IsLeft x -> IsLeft # Source # Methods Source # Methods Isomorphic IsLeft (Either () ()) Source # Methodsto' :: IsLeft -> Either () () Source # Isomorphic (Either () ()) IsLeft Source # Methodsto' :: Either () () -> IsLeft Source # type Rep IsLeft Source # type Rep IsLeft = D1 * (MetaData "IsLeft" "Control.Isomorphic" "control-iso-0.1.0.0-1BuUlR35Ufz1BYxDUvhzAC" True) (C1 * (MetaCons "IsLeft" PrefixI True) (S1 * (MetaSel (Just Symbol "unIsLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Either () ()))))

newtype IsJust Source #

A wrapper for Maybe () that decides the isomorphism to Bool is Just biased

Constructors

 IsJust FieldsunIsJust :: Maybe ()

Instances

 Source # MethodsshowsPrec :: Int -> IsJust -> ShowS #showList :: [IsJust] -> ShowS # Source # Methods Source # Methods Source # Methodsto' :: IsJust -> Maybe () Source # Source # Methodsto' :: Maybe () -> IsJust Source #

newtype IsNothing Source #

A wrapper for Maybe () that decides the isomorphism to Bool is Nothing biased

Constructors

 IsNothing FieldsunIsNothing :: Maybe ()

Instances

 Source # MethodsshowList :: [IsNothing] -> ShowS # Source # Methods Source # Methods Source # Methodsto' :: IsNothing -> Maybe () Source # Source # Methodsto' :: Maybe () -> IsNothing Source #

as :: (Isomorphic b d, Isomorphic c a) => (a -> b) -> c -> d Source #

lift a function to any types to which it is isomorphic

as2 :: (Isomorphic c f, Isomorphic d a, Isomorphic e b) => (a -> b -> c) -> d -> e -> f Source #

as3 :: (Isomorphic d h, Isomorphic e a, Isomorphic f b, Isomorphic g c) => (a -> b -> c -> d) -> e -> f -> g -> h Source #

as4 :: (Isomorphic e j, Isomorphic f a, Isomorphic g b, Isomorphic h c, Isomorphic i d) => (a -> b -> c -> d -> e) -> f -> g -> h -> i -> j Source #

as5 :: (Isomorphic f l, Isomorphic g a, Isomorphic h b, Isomorphic i c, Isomorphic j d, Isomorphic k e) => (a -> b -> c -> d -> e -> f) -> g -> h -> i -> j -> k -> l Source #

isoBi :: (Profunctor p, Isomorphic s a, Isomorphic b t, Functor f) => p a (f b) -> p s (f t) Source #

A free lens Iso s t a b from the Isomorphic instances