control-iso-0.1.0.2: A typeclass for type isomorphisms

Safe HaskellNone
LanguageHaskell2010

Control.Isomorphic

Synopsis

Documentation

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

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
Isomorphic Bool All Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Bool -> All Source #

Isomorphic Bool Any Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Bool -> Any Source #

Isomorphic Bool IsNothing Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Bool -> IsNothing Source #

Isomorphic Bool IsJust Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Bool -> IsJust Source #

Isomorphic Bool IsLeft Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Bool -> IsLeft Source #

Isomorphic Bool IsRight Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Bool -> IsRight Source #

Enum a => Isomorphic Int a Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Int -> a Source #

Coercible a b => Isomorphic a b Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: a -> b Source #

Enum a => Isomorphic a Int Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: a -> Int Source #

Isomorphic a a Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: a -> a Source #

Isomorphic All Bool Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: All -> Bool Source #

Isomorphic Any Bool Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Any -> Bool Source #

Isomorphic String ByteString Source # 
Instance details

Defined in Control.Isomorphic

Isomorphic String ByteString Source # 
Instance details

Defined in Control.Isomorphic

Isomorphic String Text Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: String -> Text Source #

Isomorphic String Text Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: String -> Text Source #

Isomorphic ByteString String Source # 
Instance details

Defined in Control.Isomorphic

Isomorphic ByteString ByteString Source # 
Instance details

Defined in Control.Isomorphic

Isomorphic ByteString Text Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: ByteString -> Text Source #

Isomorphic ByteString Text Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: ByteString -> Text Source #

Isomorphic ByteString String Source # 
Instance details

Defined in Control.Isomorphic

Isomorphic ByteString ByteString Source # 
Instance details

Defined in Control.Isomorphic

Isomorphic ByteString Text Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: ByteString -> Text Source #

Isomorphic ByteString Text Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: ByteString -> Text Source #

Isomorphic Text String Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Text -> String Source #

Isomorphic Text ByteString Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Text -> ByteString Source #

Isomorphic Text ByteString Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Text -> ByteString Source #

Isomorphic Text Text Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Text0 -> Text Source #

Isomorphic Text String Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Text -> String Source #

Isomorphic Text ByteString Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Text -> ByteString Source #

Isomorphic Text ByteString Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Text -> ByteString Source #

Isomorphic Text Text Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Text -> Text0 Source #

Isomorphic IsNothing Bool Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsNothing -> Bool Source #

Isomorphic IsJust Bool Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsJust -> Bool Source #

Isomorphic IsLeft Bool Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsLeft -> Bool Source #

Isomorphic IsRight Bool Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsRight -> Bool Source #

Isomorphic Integer (Fixed a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Integer -> Fixed a Source #

Isomorphic a (Product a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: a -> Product a Source #

Isomorphic a (Sum a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: a -> Sum a Source #

Isomorphic a (Dual a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: a -> Dual a Source #

Isomorphic a (Identity a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: a -> Identity a Source #

Isomorphic IsNothing (Maybe ()) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsNothing -> Maybe () Source #

Isomorphic IsJust (Maybe ()) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsJust -> Maybe () Source #

Isomorphic IsLeft (Either () ()) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsLeft -> Either () () Source #

Isomorphic IsRight (Either () ()) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsRight -> Either () () Source #

Isomorphic a (Const a x) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: a -> Const a x Source #

Isomorphic a (D1 d (C1 c (S1 s (K1 i a :: Type -> Type))) a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: a -> D1 d (C1 c (S1 s (K1 i a))) a Source #

Isomorphic (Maybe ()) IsNothing Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Maybe () -> IsNothing Source #

Isomorphic (Maybe ()) IsJust Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Maybe () -> IsJust Source #

Isomorphic (Fixed a) Integer Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Fixed a -> Integer Source #

Isomorphic (Identity a) a Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Identity a -> a Source #

Isomorphic (Dual a) a Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Dual a -> a Source #

Isomorphic (Sum a) a Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Sum a -> a Source #

Isomorphic (Product a) a Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Product a -> a Source #

Isomorphic [a] (ZipList a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: [a] -> ZipList a Source #

Isomorphic (Maybe a) (Last a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Maybe a -> Last a Source #

Isomorphic (Maybe a) (First a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Maybe a -> First a Source #

(Functor f, Isomorphic a b) => Isomorphic (f a) (f b) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: f a -> f b Source #

Isomorphic (ZipList a) [a] Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: ZipList a -> [a] Source #

Isomorphic (First a) (Maybe a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: First a -> Maybe a Source #

Isomorphic (Last a) (Maybe a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Last a -> Maybe a Source #

Isomorphic (Maybe a) (Either a ()) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Maybe a -> Either a () Source #

Isomorphic (Maybe a) (Either () a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Maybe a -> Either () a Source #

Isomorphic (m a) (WrappedMonad m a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: m a -> WrappedMonad m a Source #

Isomorphic (Endo a) (a -> a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Endo a -> a -> a Source #

Isomorphic (NonEmpty a) (a, [a]) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: NonEmpty a -> (a, [a]) Source #

Isomorphic (f (g a)) (Compose f g a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: f (g a) -> Compose f g a Source #

Isomorphic (Either () ()) IsLeft Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Either () () -> IsLeft Source #

Isomorphic (Either () ()) IsRight Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Either () () -> IsRight Source #

Isomorphic (a -> a) (Endo a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: (a -> a) -> Endo a Source #

Isomorphic (Either () a) (Maybe a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Either () a -> Maybe a Source #

Isomorphic (Either a ()) (Maybe a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Either a () -> Maybe a Source #

Isomorphic (a, [a]) (NonEmpty a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: (a, [a]) -> NonEmpty a Source #

Isomorphic (WrappedMonad m a) (m a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: WrappedMonad m a -> m a Source #

Isomorphic ((a, b) -> c) (a -> b -> c) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: ((a, b) -> c) -> a -> b -> c Source #

Isomorphic (a -> b -> c) (b -> a -> c) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: (a -> b -> c) -> b -> a -> c Source #

Isomorphic (a -> b -> c) ((a, b) -> c) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: (a -> b -> c) -> (a, b) -> c Source #

Isomorphic (Either a b) (Either b a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Either a b -> Either b a Source #

Isomorphic ((a, b), c) (a, (b, c)) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: ((a, b), c) -> (a, (b, c)) Source #

Isomorphic (a, (b, c)) ((a, b), c) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: (a, (b, c)) -> ((a, b), c) Source #

Isomorphic (a, b) (b, a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: (a, b) -> (b, a) Source #

Isomorphic (a () b) (ArrowMonad a b) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: a () b -> ArrowMonad a b Source #

Isomorphic (ST s a) (ST s a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: ST0 s a -> ST s a Source #

Isomorphic (ST s a) (ST s a) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: ST s a -> ST0 s a Source #

Isomorphic (ArrowMonad a b) (a () b) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: ArrowMonad a b -> a () b Source #

Isomorphic (a -> m b) (Kleisli m a b) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: (a -> m b) -> Kleisli m a b Source #

Isomorphic ((a, b), c) (a, b, c) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: ((a, b), c) -> (a, b, c) Source #

Isomorphic (a, (b, c)) (a, b, c) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: (a, (b, c)) -> (a, b, c) Source #

Isomorphic (a b c) (WrappedArrow a b c) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: a b c -> WrappedArrow a b c Source #

Isomorphic (Const a x) a Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Const a x -> a Source #

Isomorphic (a, b, c) ((a, b), c) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: (a, b, c) -> ((a, b), c) Source #

Isomorphic (a, b, c) (a, (b, c)) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: (a, b, c) -> (a, (b, c)) Source #

Isomorphic (WrappedArrow a b c) (a b c) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: WrappedArrow a b c -> a b c Source #

Isomorphic (Kleisli m a b) (a -> m b) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Kleisli m a b -> a -> m b Source #

Isomorphic (D1 d (C1 c (S1 s (K1 i a :: Type -> Type))) a) a Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: D1 d (C1 c (S1 s (K1 i a))) a -> a Source #

Isomorphic (Compose f g a) (f (g a)) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: 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 

Fields

Instances
Show IsRight Source # 
Instance details

Defined in Control.Isomorphic

Generic IsRight Source # 
Instance details

Defined in Control.Isomorphic

Associated Types

type Rep IsRight :: Type -> Type #

Methods

from :: IsRight -> Rep IsRight x #

to :: Rep IsRight x -> IsRight #

Isomorphic Bool IsRight Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Bool -> IsRight Source #

Isomorphic IsRight Bool Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsRight -> Bool Source #

Isomorphic IsRight (Either () ()) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsRight -> Either () () Source #

Isomorphic (Either () ()) IsRight Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Either () () -> IsRight Source #

type Rep IsRight Source # 
Instance details

Defined in Control.Isomorphic

type Rep IsRight = D1 (MetaData "IsRight" "Control.Isomorphic" "control-iso-0.1.0.2-EG67WcOEfRSL1q1q9OrCZc" True) (C1 (MetaCons "IsRight" PrefixI True) (S1 (MetaSel (Just "unIsRight") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Either () ()))))

newtype IsLeft Source #

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

Constructors

IsLeft 

Fields

Instances
Show IsLeft Source # 
Instance details

Defined in Control.Isomorphic

Generic IsLeft Source # 
Instance details

Defined in Control.Isomorphic

Associated Types

type Rep IsLeft :: Type -> Type #

Methods

from :: IsLeft -> Rep IsLeft x #

to :: Rep IsLeft x -> IsLeft #

Isomorphic Bool IsLeft Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Bool -> IsLeft Source #

Isomorphic IsLeft Bool Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsLeft -> Bool Source #

Isomorphic IsLeft (Either () ()) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsLeft -> Either () () Source #

Isomorphic (Either () ()) IsLeft Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Either () () -> IsLeft Source #

type Rep IsLeft Source # 
Instance details

Defined in Control.Isomorphic

type Rep IsLeft = D1 (MetaData "IsLeft" "Control.Isomorphic" "control-iso-0.1.0.2-EG67WcOEfRSL1q1q9OrCZc" True) (C1 (MetaCons "IsLeft" PrefixI True) (S1 (MetaSel (Just "unIsLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Either () ()))))

newtype IsJust Source #

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

Constructors

IsJust 

Fields

Instances
Show IsJust Source # 
Instance details

Defined in Control.Isomorphic

Isomorphic Bool IsJust Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Bool -> IsJust Source #

Isomorphic IsJust Bool Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsJust -> Bool Source #

Isomorphic IsJust (Maybe ()) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsJust -> Maybe () Source #

Isomorphic (Maybe ()) IsJust Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Maybe () -> IsJust Source #

newtype IsNothing Source #

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

Constructors

IsNothing 

Fields

Instances
Show IsNothing Source # 
Instance details

Defined in Control.Isomorphic

Isomorphic Bool IsNothing Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: Bool -> IsNothing Source #

Isomorphic IsNothing Bool Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsNothing -> Bool Source #

Isomorphic IsNothing (Maybe ()) Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: IsNothing -> Maybe () Source #

Isomorphic (Maybe ()) IsNothing Source # 
Instance details

Defined in Control.Isomorphic

Methods

to' :: 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