fresnel-0.1.0.1: high-powered optics in a small package
Safe HaskellNone
LanguageHaskell2010

Fresnel.Iso

Description

Isos 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.

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 Iso consists of functions f and g which are mutual inverses:

f . g = id
g . f = id
Synopsis

Isos

type Iso s t a b = forall (p :: Type -> Type -> Type). IsIso p => Optic p s t a b Source #

type Iso' s a = Iso s s a a Source #

class Profunctor p => IsIso (p :: Type -> Type -> Type) Source #

Instances

Instances details
Functor f => IsIso (OptionalStar f) Source # 
Instance details

Defined in Fresnel.Iso.Internal

IsIso (Recall e) Source # 
Instance details

Defined in Fresnel.Iso.Internal

Functor f => IsIso (Star1 f) Source # 
Instance details

Defined in Fresnel.Iso.Internal

Monad m => IsIso (Kleisli m) Source # 
Instance details

Defined in Fresnel.Iso.Internal

IsIso (UnpackedLens a b) Source # 
Instance details

Defined in Fresnel.Lens

IsIso (UnpackedOptional a b) Source # 
Instance details

Defined in Fresnel.Optional

IsIso (UnpackedPrism a b) Source # 
Instance details

Defined in Fresnel.Prism

IsIso (Coexp s t) Source # 
Instance details

Defined in Fresnel.Iso.Internal

Functor f => IsIso (Costar f) Source # 
Instance details

Defined in Fresnel.Iso.Internal

IsIso (Forget r :: Type -> Type -> Type) Source # 
Instance details

Defined in Fresnel.Iso.Internal

Functor f => IsIso (Star f) Source # 
Instance details

Defined in Fresnel.Iso.Internal

IsIso (->) Source # 
Instance details

Defined in Fresnel.Iso.Internal

Construction

iso :: (s -> a) -> (b -> t) -> Iso s t a b Source #

from :: Iso s t a b -> Iso b a t s Source #

Elimination

withIso :: Iso s t a b -> ((s -> a) -> (b -> t) -> r) -> r Source #

under :: Iso s t a b -> (t -> s) -> b -> a Source #

Functions

constant :: a -> Iso (a -> b) (a' -> b') b b' Source #

constantWith :: a -> (b' -> a' -> b') -> Iso (a -> b) (a' -> b') b b' Source #

involuted :: (a -> a) -> Iso' a a 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 #

au :: Functor f => Iso s t a b -> ((b -> t) -> f s) -> f a Source #

auf :: (Functor f, Functor g) => Iso s t a b -> (f t -> g s) -> f b -> g a Source #

Relations

non :: Eq a => a -> Iso' (Maybe a) a Source #

non' :: Prism' a () -> Iso' (Maybe a) a Source #

Tuples

swapped :: forall a b a' b' p. IsIso p => Optic p (a, b) (a', b') (b, a) (b', a') Source #

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

coerced :: (Coercible s a, Coercible t b) => Iso s t a b Source #

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 #