Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- class Isomorphic b a => Isomorphic a b where
- via :: forall b a c. (Isomorphic b c, Isomorphic a b) => a -> c
- to :: forall b a. Isomorphic a b => a -> b
- from :: forall a b. Isomorphic a b => a -> b
- newtype IsRight = IsRight {}
- newtype IsLeft = IsLeft {}
- newtype IsJust = IsJust {}
- newtype IsNothing = IsNothing {
- unIsNothing :: Maybe ()
- as :: (Isomorphic b d, Isomorphic c a) => (a -> b) -> c -> d
- as2 :: (Isomorphic c f, Isomorphic d a, Isomorphic e b) => (a -> b -> c) -> d -> e -> f
- as3 :: (Isomorphic d h, Isomorphic e a, Isomorphic f b, Isomorphic g c) => (a -> b -> c -> d) -> e -> f -> g -> h
- 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
- 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
- isoBi :: (Profunctor p, Isomorphic s a, Isomorphic b t, Functor f) => p a (f b) -> p s (f t)
Documentation
class Isomorphic b a => Isomorphic a b where 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.
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.
IsNothing | |
|
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