control-iso-0.1.0.1: A typeclass for type isomorphisms

Safe HaskellSafe
LanguageHaskell2010

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

Isomorphic Bool All Source # 

Methods

to' :: Bool -> All Source #

Isomorphic Bool Any Source # 

Methods

to' :: Bool -> Any Source #

Isomorphic Bool IsNothing Source # 

Methods

to' :: Bool -> IsNothing Source #

Isomorphic Bool IsJust Source # 

Methods

to' :: Bool -> IsJust Source #

Isomorphic Bool IsLeft Source # 

Methods

to' :: Bool -> IsLeft Source #

Isomorphic Bool IsRight Source # 

Methods

to' :: Bool -> IsRight Source #

Enum a => Isomorphic Int a Source # 

Methods

to' :: Int -> a Source #

Enum a => Isomorphic a Int Source # 

Methods

to' :: a -> Int Source #

Isomorphic a a Source # 

Methods

to' :: a -> a Source #

Isomorphic All Bool Source # 

Methods

to' :: All -> Bool Source #

Isomorphic Any Bool Source # 

Methods

to' :: Any -> Bool Source #

Isomorphic String ByteString Source # 
Isomorphic String ByteString Source # 
Isomorphic String Text Source # 

Methods

to' :: String -> Text Source #

Isomorphic String Text Source # 

Methods

to' :: String -> Text Source #

Isomorphic ByteString String Source # 
Isomorphic ByteString ByteString Source # 
Isomorphic ByteString Text Source # 

Methods

to' :: ByteString -> Text Source #

Isomorphic ByteString Text Source # 

Methods

to' :: ByteString -> Text Source #

Isomorphic ByteString String Source # 
Isomorphic ByteString ByteString Source # 
Isomorphic ByteString Text Source # 

Methods

to' :: ByteString -> Text Source #

Isomorphic ByteString Text Source # 

Methods

to' :: ByteString -> Text Source #

Isomorphic Text String Source # 

Methods

to' :: Text -> String Source #

Isomorphic Text ByteString Source # 

Methods

to' :: Text -> ByteString Source #

Isomorphic Text ByteString Source # 

Methods

to' :: Text -> ByteString Source #

Isomorphic Text Text Source # 

Methods

to' :: Text -> Text Source #

Isomorphic Text String Source # 

Methods

to' :: Text -> String Source #

Isomorphic Text ByteString Source # 

Methods

to' :: Text -> ByteString Source #

Isomorphic Text ByteString Source # 

Methods

to' :: Text -> ByteString Source #

Isomorphic Text Text Source # 

Methods

to' :: Text -> Text Source #

Isomorphic IsNothing Bool Source # 

Methods

to' :: IsNothing -> Bool Source #

Isomorphic IsJust Bool Source # 

Methods

to' :: IsJust -> Bool Source #

Isomorphic IsLeft Bool Source # 

Methods

to' :: IsLeft -> Bool Source #

Isomorphic IsRight Bool Source # 

Methods

to' :: IsRight -> Bool Source #

Isomorphic Integer (Fixed a) Source # 

Methods

to' :: Integer -> Fixed a Source #

Isomorphic a (Product a) Source # 

Methods

to' :: a -> Product a Source #

Isomorphic a (Sum a) Source # 

Methods

to' :: a -> Sum a Source #

Isomorphic a (Dual a) Source # 

Methods

to' :: a -> Dual a Source #

Isomorphic a (Identity a) Source # 

Methods

to' :: a -> Identity a Source #

Isomorphic IsNothing (Maybe ()) Source # 

Methods

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

Isomorphic IsJust (Maybe ()) Source # 

Methods

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

Isomorphic IsLeft (Either () ()) Source # 

Methods

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

Isomorphic IsRight (Either () ()) Source # 

Methods

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

Isomorphic a (Const * a x) Source # 

Methods

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

Isomorphic a (D1 * d (C1 * c (S1 * s (K1 * i a))) a) Source # 

Methods

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

Isomorphic (Maybe ()) IsNothing Source # 

Methods

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

Isomorphic (Maybe ()) IsJust Source # 

Methods

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

Isomorphic (Fixed a) Integer Source # 

Methods

to' :: Fixed a -> Integer Source #

Isomorphic (Identity a) a Source # 

Methods

to' :: Identity a -> a Source #

Isomorphic (Dual a) a Source # 

Methods

to' :: Dual a -> a Source #

Isomorphic (Sum a) a Source # 

Methods

to' :: Sum a -> a Source #

Isomorphic (Product a) a Source # 

Methods

to' :: Product a -> a Source #

Isomorphic [a] (ZipList a) Source # 

Methods

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

Isomorphic (Maybe a) (Last a) Source # 

Methods

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

Isomorphic (Maybe a) (First a) Source # 

Methods

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

Isomorphic (ZipList a) [a] Source # 

Methods

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

Isomorphic (First a) (Maybe a) Source # 

Methods

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

Isomorphic (Last a) (Maybe a) Source # 

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

Isomorphic (f (g a)) (Compose * * f g a) Source # 

Methods

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

Isomorphic (Either () ()) IsLeft Source # 

Methods

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

Isomorphic (Either () ()) IsRight Source # 

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

Isomorphic (Const * a x) a Source # 

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

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

Methods

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

Isomorphic (D1 * d (C1 * c (S1 * s (K1 * i a))) a) a Source # 

Methods

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

Isomorphic (Compose * * f g a) (f (g a)) Source # 

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 # 
Generic IsRight Source # 

Associated Types

type Rep IsRight :: * -> * #

Methods

from :: IsRight -> Rep IsRight x #

to :: Rep IsRight x -> IsRight #

Isomorphic Bool IsRight Source # 

Methods

to' :: Bool -> IsRight Source #

Isomorphic IsRight Bool Source # 

Methods

to' :: IsRight -> Bool Source #

Isomorphic IsRight (Either () ()) Source # 

Methods

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

Isomorphic (Either () ()) IsRight Source # 

Methods

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

type Rep IsRight Source # 
type Rep IsRight = D1 * (MetaData "IsRight" "Control.Isomorphic" "control-iso-0.1.0.1-Eu3g13fdvY3L1UwRhfemnL" 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 

Fields

Instances

Show IsLeft Source # 
Generic IsLeft Source # 

Associated Types

type Rep IsLeft :: * -> * #

Methods

from :: IsLeft -> Rep IsLeft x #

to :: Rep IsLeft x -> IsLeft #

Isomorphic Bool IsLeft Source # 

Methods

to' :: Bool -> IsLeft Source #

Isomorphic IsLeft Bool Source # 

Methods

to' :: IsLeft -> Bool Source #

Isomorphic IsLeft (Either () ()) Source # 

Methods

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

Isomorphic (Either () ()) IsLeft Source # 

Methods

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

type Rep IsLeft Source # 
type Rep IsLeft = D1 * (MetaData "IsLeft" "Control.Isomorphic" "control-iso-0.1.0.1-Eu3g13fdvY3L1UwRhfemnL" 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 

Fields

newtype IsNothing Source #

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

Constructors

IsNothing 

Fields

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