Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
s are the root of the optic hierarchy: an Iso
can be used anywhere any other kind of optic is required. On the other hand, if something requests an Iso
, it can only be given an Iso
, as it doesn't provide enough capabilities to accept anything else.Iso
This implies that they're the weakest optic; they make the fewest assumptions, and thus can provide only the most minimal guarantees. Even so, these guarantees are relativevly strong: notionally, an
consists of functions Iso
f
and g
which are mutual inverses:
f.
g =id
g.
f =id
Synopsis
- type Iso s t a b = forall p. IsIso p => Optic p s t a b
- type Iso' s a = Iso s s a a
- class Profunctor p => IsIso p
- iso :: (s -> a) -> (b -> t) -> Iso s t a b
- from :: Iso s t a b -> Iso b a t s
- withIso :: Iso s t a b -> ((s -> a) -> (b -> t) -> r) -> r
- under :: Iso s t a b -> (t -> s) -> b -> a
- constant :: a -> Iso (a -> b) (a' -> b') b b'
- constantWith :: a -> (b' -> a' -> b') -> Iso (a -> b) (a' -> b') b b'
- involuted :: (a -> a) -> Iso' a a
- flipped :: Iso (a -> b -> c) (a' -> b' -> c') (b -> a -> c) (b' -> a' -> c')
- curried :: Iso ((a, b) -> c) ((a', b') -> c') (a -> b -> c) (a' -> b' -> c')
- uncurried :: Iso (a -> b -> c) (a' -> b' -> c') ((a, b) -> c) ((a', b') -> c')
- non :: Eq a => a -> Iso' (Maybe a) a
- non' :: Prism' a () -> Iso' (Maybe a) a
- swapped :: Iso (a, b) (a', b') (b, a) (b', a')
- mirrored :: Iso (Either a b) (Either a' b') (Either b a) (Either b' a')
- coerced :: (Coercible s a, Coercible t b) => Iso s t a b
- coercedTo :: Coercible t b => (s -> a) -> Iso s t a b
- coercedFrom :: Coercible s a => (b -> t) -> Iso s t a b
- fmapping :: (Functor f, Functor g) => Iso s t a b -> Iso (f s) (g t) (f a) (g b)
- contramapping :: (Contravariant f, Contravariant g) => Iso s t a b -> Iso (f a) (g b) (f s) (g t)
- bimapping :: (Bifunctor p, Bifunctor q) => Iso s t a b -> Iso s' t' a' b' -> Iso (p s s') (q t t') (p a a') (q b b')
- firsting :: (Bifunctor p, Bifunctor q) => Iso s t a b -> Iso (p s x) (q t y) (p a x) (q b y)
- seconding :: (Bifunctor p, Bifunctor q) => Iso s t a b -> Iso (p x s) (q y t) (p x a) (q y b)
- dimapping :: (Profunctor p, Profunctor q) => Iso s t a b -> Iso s' t' a' b' -> Iso (p a s') (q b t') (p s a') (q t b')
- lmapping :: (Profunctor p, Profunctor q) => Iso s t a b -> Iso (p a x) (q b y) (p s x) (q t y)
- rmapping :: (Profunctor p, Profunctor q) => Iso s t a b -> Iso (p x s) (q y t) (p x a) (q y b)
- protabulated :: (Representable p, Representable q) => Iso (a -> Rep p b) (a' -> Rep q b') (p a b) (q a' b')
- cotabulated :: (Corepresentable p, Corepresentable q) => Iso (Corep p a -> b) (Corep q a' -> b') (p a b) (q a' b')
Isos
class Profunctor p => IsIso p Source #
Instances
Monad m => IsIso (Kleisli m) Source # | |
Defined in Fresnel.Iso.Internal | |
Functor f => IsIso (OptionalStar f) Source # | |
Defined in Fresnel.Iso.Internal | |
IsIso (Recall e) Source # | |
Defined in Fresnel.Iso.Internal | |
IsIso (UnpackedLens a b) Source # | |
Defined in Fresnel.Lens | |
IsIso (UnpackedOptional a b) Source # | |
Defined in Fresnel.Optional | |
IsIso (UnpackedPrism a b) Source # | |
Defined in Fresnel.Prism | |
IsIso (Coexp s t) Source # | |
Defined in Fresnel.Iso.Internal | |
Functor f => IsIso (Costar f) Source # | |
Defined in Fresnel.Iso.Internal | |
IsIso (Forget r :: Type -> Type -> TYPE LiftedRep) Source # | |
Defined in Fresnel.Iso.Internal | |
Functor f => IsIso (Star f) Source # | |
Defined in Fresnel.Iso.Internal | |
IsIso (->) Source # | |
Defined in Fresnel.Iso.Internal |
Construction
Elimination
Functions
constantWith :: a -> (b' -> a' -> b') -> Iso (a -> b) (a' -> b') b b' Source #
Relations
Tuples
Coercion
coercedTo :: Coercible t b => (s -> a) -> Iso s t a b Source #
Build a bidi coercion, taking a constructor for the type being built both to improve type inference and as documentation.
For example, given two newtypes A
and B
wrapping the same type, this expression:
coercedTo
B <<<coercedFrom
A
produces a bijection of type
.Iso'
A B
coercedFrom :: Coercible s a => (b -> t) -> Iso s t a b Source #
Build a bidi coercion, taking a constructor for the type being eliminated both to improve type inference and as documentation.
For example, given two newtypes A
and B
wrapping the same type, this expression:
coercedTo
B <<<coercedFrom
A
produces a bijection of type
.Iso'
A B
Functor
Contravariant
contramapping :: (Contravariant f, Contravariant g) => Iso s t a b -> Iso (f a) (g b) (f s) (g t) Source #
Bifunctor
bimapping :: (Bifunctor p, Bifunctor q) => Iso s t a b -> Iso s' t' a' b' -> Iso (p s s') (q t t') (p a a') (q b b') Source #
firsting :: (Bifunctor p, Bifunctor q) => Iso s t a b -> Iso (p s x) (q t y) (p a x) (q b y) Source #
seconding :: (Bifunctor p, Bifunctor q) => Iso s t a b -> Iso (p x s) (q y t) (p x a) (q y b) Source #
Profunctor
dimapping :: (Profunctor p, Profunctor q) => Iso s t a b -> Iso s' t' a' b' -> Iso (p a s') (q b t') (p s a') (q t b') Source #
lmapping :: (Profunctor p, Profunctor q) => Iso s t a b -> Iso (p a x) (q b y) (p s x) (q t y) Source #
rmapping :: (Profunctor p, Profunctor q) => Iso s t a b -> Iso (p x s) (q y t) (p x a) (q y b) Source #
(Co-)representable
protabulated :: (Representable p, Representable q) => Iso (a -> Rep p b) (a' -> Rep q b') (p a b) (q a' b') Source #
cotabulated :: (Corepresentable p, Corepresentable q) => Iso (Corep p a -> b) (Corep q a' -> b') (p a b) (q a' b') Source #