profunctor-optics-0.0.2: A compact optics library compatible with the typeclasses in profunctors.

Data.Profunctor.Optic.Types

Synopsis

# Optic

type Optic p s t a b = p a b -> p s t Source #

type Optic' p s a = Optic p s s a a Source #

# Constraints

type Affine p = (Choice p, Strong p) Source #

type Coaffine p = (Choice p, Closed p) Source #

type CoerceR p = forall x. Contravariant (p x) Source #

# Equality

type Equality s t a b = forall p. Optic p s t a b Source #

$$\mathsf{Equality}\;A = A \cong A$$

type Equality' s a = Equality s s a a Source #

# Iso

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

$$\mathsf{Iso}\;S\;A = S \cong A$$

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

# Prism

type Prism s t a b = forall p. Choice p => Optic p s t a b Source #

$$\mathsf{Prism}\;S\;A = \exists D, S \cong D + A$$

type Coprism s t a b = forall p. Cochoice p => Optic p s t a b Source #

$$\mathsf{Prism}\;S\;A = \exists D, S + D \cong A$$

type Prism' s a = Prism s s a a Source #

type Coprism' t b = Coprism t t b b Source #

# Lens

type Lens s t a b = forall p. Strong p => Optic p s t a b Source #

$$\mathsf{Lens}\;S\;A = \exists C, S \cong C \times A$$

type Colens s t a b = forall p. Costrong p => Optic p s t a b Source #

$$\mathsf{Lens}\;S\;A = \exists C, S \times C \cong A$$

type Lens' s a = Lens s s a a Source #

type Colens' t b = Lens t t b b Source #

# Grate

type Grate s t a b = forall p. Closed p => Optic p s t a b Source #

$$\mathsf{Grate}\;S\;A = \exists I, S \cong I \to A$$

type Grate' s a = Grate s s a a Source #

# Traversal

type Traversal0 s t a b = forall p. Affine p => Optic p s t a b Source #

$$\mathsf{Traversal0}\;S\;A = \exists C, D, S \cong D + C \times A$$

type Cotraversal0 s t a b = forall p. Coaffine p => Optic p s t a b Source #

$$\mathsf{Cotraversal0}\;S\;A = \exists D, I, S \cong I \to D + A$$

type Traversal s t a b = forall p. (Affine p, Traversing p) => Optic p s t a b Source #

$$\mathsf{Traversal}\;S\;A = \exists F : \mathsf{Traversable}, S \equiv F\,A$$

type Cotraversal s t a b = forall p. (Coaffine p, Cotraversing p) => Optic p s t a b Source #

$$\mathsf{Cotraversal}\;S\;A = \exists F : \mathsf{Distributive}, S \equiv F\,A$$

type Traversal1 s t a b = forall p. (Strong p, Traversing1 p) => Optic p s t a b Source #

$$\mathsf{Traversal1}\;S\;A = \exists F : \mathsf{Traversable1}, S \equiv F\,A$$

type Cotraversal1 s t a b = forall p. (Closed p, Cotraversing1 p) => Optic p s t a b Source #

$$\mathsf{Cotraversal1}\;S\;A = \exists F : \mathsf{Distributive1}, S \equiv F\,A$$

type Traversal0' s a = Traversal0 s s a a Source #

type Cotraversal0' t b = Cotraversal0 t t b b Source #

type Traversal' s a = Traversal s s a a Source #

type Cotraversal' t b = Cotraversal t t b b Source #

type Traversal1' s a = Traversal1 s s a a Source #

type Cotraversal1' t b = Cotraversal1 t t b b Source #

# Fold

type Fold0 s a = forall p. (Affine p, CoerceR p) => Optic' p s a Source #

type Fold s a = forall p. (Affine p, Traversing p, CoerceR p) => Optic' p s a Source #

type Fold1 s a = forall p. (Strong p, Traversing1 p, CoerceR p) => Optic' p s a Source #

# Setter

type Setter s t a b = forall p. (Affine p, Traversing p, Mapping p) => Optic p s t a b Source #

$$\mathsf{Setter}\;S\;A = \exists F : \mathsf{Functor}, S \equiv F\,A$$

type Resetter s t a b = forall p. (Coaffine p, Cotraversing p, Comapping p) => Optic p s t a b Source #

$$\mathsf{Setter}\;S\;A = \exists F : \mathsf{Functor}, F\,S \equiv A$$

type Setter' s a = Setter s s a a Source #

type Resetter' s a = Resetter s s a a Source #

# View

type View s a = forall p. (Strong p, CoerceR p) => Optic' p s a Source #

type Review t b = forall p. (Closed p, CoerceL p) => Optic' p t b Source #

# Re

newtype Re p s t a b Source #

The Re type and its instances witness the symmetry between the parameters of a Profunctor.

Constructors

 Re FieldsrunRe :: p b a -> p t s
Instances
 (Profunctor p, forall x. Contravariant (p x)) => Bifunctor (Re p s t) Source # Instance detailsDefined in Data.Profunctor.Optic.Types Methodsbimap :: (a -> b) -> (c -> d) -> Re p s t a c -> Re p s t b d #first :: (a -> b) -> Re p s t a c -> Re p s t b c #second :: (b -> c) -> Re p s t a b -> Re p s t a c # Cochoice p => Choice (Re p s t) Source # Instance detailsDefined in Data.Profunctor.Optic.Types Methodsleft' :: Re p s t a b -> Re p s t (Either a c) (Either b c) #right' :: Re p s t a b -> Re p s t (Either c a) (Either c b) # Choice p => Cochoice (Re p s t) Source # Instance detailsDefined in Data.Profunctor.Optic.Types Methodsunleft :: Re p s t (Either a d) (Either b d) -> Re p s t a b #unright :: Re p s t (Either d a) (Either d b) -> Re p s t a b # Costrong p => Strong (Re p s t) Source # Instance detailsDefined in Data.Profunctor.Optic.Types Methodsfirst' :: Re p s t a b -> Re p s t (a, c) (b, c) #second' :: Re p s t a b -> Re p s t (c, a) (c, b) # Strong p => Costrong (Re p s t) Source # Instance detailsDefined in Data.Profunctor.Optic.Types Methodsunfirst :: Re p s t (a, d) (b, d) -> Re p s t a b #unsecond :: Re p s t (d, a) (d, b) -> Re p s t a b # Profunctor p => Profunctor (Re p s t) Source # Instance detailsDefined in Data.Profunctor.Optic.Types Methodsdimap :: (a -> b) -> (c -> d) -> Re p s t b c -> Re p s t a d #lmap :: (a -> b) -> Re p s t b c -> Re p s t a c #rmap :: (b -> c) -> Re p s t a b -> Re p s t a c #(#.) :: Coercible c b => q b c -> Re p s t a b -> Re p s t a c #(.#) :: Coercible b a => Re p s t b c -> q a b -> Re p s t a c # Bifunctor p => Contravariant (Re p s t a) Source # Instance detailsDefined in Data.Profunctor.Optic.Types Methodscontramap :: (a0 -> b) -> Re p s t a b -> Re p s t a a0 #(>\$) :: b -> Re p s t a b -> Re p s t a a0 #

re :: Optic (Re p a b) s t a b -> Optic p b a t s Source #

Reverse an optic to obtain its dual.

re . re  ≡ id

re :: Iso s t a b   -> Iso b a t s
re :: Lens s t a b  -> Colens b a t s
re :: Prism s t a b -> Coprism b a t s
re :: Traversal s t a b  -> Cotraversal b a t s
re :: View s t a b  -> Review b a t s

>>> 5 ^. re left'
Left 5


between :: (c -> d) -> (a -> b) -> (b -> c) -> a -> d Source #

Can be used to rewrite

\g -> f . g . h

to

between f h

# Orphan instances

 Contravariant f => Bifunctor (Costar f) Source # Instance details Methodsbimap :: (a -> b) -> (c -> d) -> Costar f a c -> Costar f b d #first :: (a -> b) -> Costar f a c -> Costar f b c #second :: (b -> c) -> Costar f a b -> Costar f a c # Coapplicative f => Choice (Costar f) Source # Instance details Methodsleft' :: Costar f a b -> Costar f (Either a c) (Either b c) #right' :: Costar f a b -> Costar f (Either c a) (Either c b) # Apply f => Apply (Star f a) Source # Instance details Methods(<.>) :: Star f a (a0 -> b) -> Star f a a0 -> Star f a b #(.>) :: Star f a a0 -> Star f a b -> Star f a b #(<.) :: Star f a a0 -> Star f a b -> Star f a a0 #liftF2 :: (a0 -> b -> c) -> Star f a a0 -> Star f a b -> Star f a c # Apply (Costar f a) Source # Instance details Methods(<.>) :: Costar f a (a0 -> b) -> Costar f a a0 -> Costar f a b #(.>) :: Costar f a a0 -> Costar f a b -> Costar f a b #(<.) :: Costar f a a0 -> Costar f a b -> Costar f a a0 #liftF2 :: (a0 -> b -> c) -> Costar f a a0 -> Costar f a b -> Costar f a c #