Safe Haskell | None |
---|---|
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 :: Type -> Type -> Type). IsIso p => Optic p s t a b
- type Iso' s a = Iso s s a a
- class Profunctor p => IsIso (p :: Type -> Type -> Type)
- 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 :: forall a b c a' b' c' p. IsIso p => Optic p (a -> b -> c) (a' -> b' -> c') (b -> a -> c) (b' -> a' -> c')
- curried :: forall a b c a' b' c' p. IsIso p => Optic p ((a, b) -> c) ((a', b') -> c') (a -> b -> c) (a' -> b' -> c')
- uncurried :: forall a b c a' b' c' p. IsIso p => Optic p (a -> b -> c) (a' -> b' -> c') ((a, b) -> c) ((a', b') -> c')
- au :: Functor f => Iso s t a b -> ((b -> t) -> f s) -> f a
- auf :: (Functor f, Functor g) => Iso s t a b -> (f t -> g s) -> f b -> g a
- non :: Eq a => a -> Iso' (Maybe a) a
- non' :: Prism' a () -> Iso' (Maybe a) a
- swapped :: forall a b a' b' p. IsIso p => Optic p (a, b) (a', b') (b, a) (b', a')
- mirrored :: forall a b a' b' p. IsIso p => Optic p (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 :: forall (f :: Type -> Type) (g :: Type -> Type) s t a b. (Functor f, Functor g) => Iso s t a b -> Iso (f s) (g t) (f a) (g b)
- contramapping :: forall (f :: Type -> Type) (g :: Type -> Type) s t a b. (Contravariant f, Contravariant g) => Iso s t a b -> Iso (f a) (g b) (f s) (g t)
- bimapping :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b s' t' a' b'. (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 :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b x y. (Bifunctor p, Bifunctor q) => Iso s t a b -> Iso (p s x) (q t y) (p a x) (q b y)
- seconding :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b x y. (Bifunctor p, Bifunctor q) => Iso s t a b -> Iso (p x s) (q y t) (p x a) (q y b)
- dimapping :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b s' t' a' b'. (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 :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b x y. (Profunctor p, Profunctor q) => Iso s t a b -> Iso (p a x) (q b y) (p s x) (q t y)
- rmapping :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b x y. (Profunctor p, Profunctor q) => Iso s t a b -> Iso (p x s) (q y t) (p x a) (q y b)
- protabulated :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) a b a' b'. (Representable p, Representable q) => Iso (a -> Rep p b) (a' -> Rep q b') (p a b) (q a' b')
- cotabulated :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) a b a' b'. (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 :: Type -> Type -> Type) Source #
Instances
Functor f => IsIso (OptionalStar f) Source # | |
Defined in Fresnel.Iso.Internal | |
IsIso (Recall e) Source # | |
Defined in Fresnel.Iso.Internal | |
Functor f => IsIso (Star1 f) Source # | |
Defined in Fresnel.Iso.Internal | |
Monad m => IsIso (Kleisli m) 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) 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 #
flipped :: forall a b c a' b' c' p. IsIso p => Optic p (a -> b -> c) (a' -> b' -> c') (b -> a -> c) (b' -> a' -> c') Source #
curried :: forall a b c a' b' c' p. IsIso p => Optic p ((a, b) -> c) ((a', b') -> c') (a -> b -> c) (a' -> b' -> c') Source #
uncurried :: forall a b c a' b' c' p. IsIso p => Optic p (a -> b -> c) (a' -> b' -> c') ((a, b) -> c) ((a', b') -> c') Source #
Relations
Tuples
mirrored :: forall a b a' b' p. IsIso p => Optic p (Either a b) (Either a' b') (Either b a) (Either b' a') Source #
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
fmapping :: forall (f :: Type -> Type) (g :: Type -> Type) s t a b. (Functor f, Functor g) => Iso s t a b -> Iso (f s) (g t) (f a) (g b) Source #
Contravariant
contramapping :: forall (f :: Type -> Type) (g :: Type -> Type) s t a b. (Contravariant f, Contravariant g) => Iso s t a b -> Iso (f a) (g b) (f s) (g t) Source #
Bifunctor
bimapping :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b s' t' a' b'. (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 :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b x y. (Bifunctor p, Bifunctor q) => Iso s t a b -> Iso (p s x) (q t y) (p a x) (q b y) Source #
seconding :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b x y. (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 :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b s' t' a' b'. (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 :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b x y. (Profunctor p, Profunctor q) => Iso s t a b -> Iso (p a x) (q b y) (p s x) (q t y) Source #
rmapping :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) s t a b x y. (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 :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) a b a' b'. (Representable p, Representable q) => Iso (a -> Rep p b) (a' -> Rep q b') (p a b) (q a' b') Source #
cotabulated :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type) a b a' b'. (Corepresentable p, Corepresentable q) => Iso (Corep p a -> b) (Corep q a' -> b') (p a b) (q a' b') Source #