fresnel-0.0.0.1: high-powered optics in a small package
Safe HaskellSafe-Inferred
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
  • 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

type Iso s t a b = forall p. IsIso p => Optic p s t a b Source #

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

class Profunctor p => IsIso p Source #

Instances

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

Defined in Fresnel.Iso.Internal

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

Defined in Fresnel.Iso.Internal

IsIso (Recall e) 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 LiftedRep) 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 :: Iso (a -> b -> c) (a' -> b' -> c') (b -> a -> c) (b' -> a' -> c') Source #

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

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

Relations

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

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

Tuples

swapped :: Iso (a, b) (a', b') (b, a) (b', a') Source #

mirrored :: Iso (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 :: (Functor f, Functor g) => Iso s t a b -> Iso (f s) (g t) (f a) (g b) Source #

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 #