lens-4.19.1: Lenses, Folds and Traversals

Control.Lens.Equality

Description

Synopsis

# Type Equality

type Equality (s :: k1) (t :: k2) (a :: k1) (b :: k2) = forall k3 (p :: k1 -> k3 -> Type) (f :: k2 -> k3). p a (f b) -> p s (f t) Source #

A witness that (a ~ s, b ~ t).

Note: Composition with an Equality is index-preserving.

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

A Simple Equality.

type AnEquality (s :: k1) (t :: k2) (a :: k1) (b :: k2) = Identical a (Proxy b) a (Proxy b) -> Identical a (Proxy b) s (Proxy t) Source #

When you see this as an argument to a function, it expects an Equality.

type AnEquality' s a = AnEquality s s a a Source #

A Simple AnEquality.

data (a :: k) :~: (b :: k) :: forall k. k -> k -> Type where infix 4 #

Propositional equality. If a :~: b is inhabited by some terminating value, then the type a is the same as the type b. To use this equality in practice, pattern-match on the a :~: b to get out the Refl constructor; in the body of the pattern-match, the compiler knows that a ~ b.

Since: base-4.7.0.0

Constructors

 Refl :: forall k (a :: k) (b :: k). a :~: a
Instances

runEq :: AnEquality s t a b -> Identical s t a b Source #

Extract a witness of type Equality.

substEq :: forall s t a b rep (r :: TYPE rep). AnEquality s t a b -> ((s ~ a, t ~ b) => r) -> r Source #

Substituting types with Equality.

mapEq :: forall k1 k2 (s :: k1) (t :: k2) (a :: k1) (b :: k2) (f :: k1 -> Type). AnEquality s t a b -> f s -> f a Source #

We can use Equality to do substitution into anything.

fromEq :: AnEquality s t a b -> Equality b a t s Source #

Equality is symmetric.

simply :: forall p f s a rep (r :: TYPE rep). (Optic' p f s a -> r) -> Optic' p f s a -> r Source #

This is an adverb that can be used to modify many other Lens combinators to make them require simple lenses, simple traversals, simple prisms or simple isos as input.

# The Trivial Equality

Composition with this isomorphism is occasionally useful when your Lens, Traversal or Iso has a constraint on an unused argument to force that argument to agree with the type of a used argument and avoid ScopedTypeVariables or other ugliness.

# Iso-like functions

equality :: (s :~: a) -> (b :~: t) -> Equality s t a b Source #

Construct an Equality from explicit equality evidence.

equality' :: (a :~: b) -> Equality' a b Source #

A Simple version of equality

withEquality :: forall s t a b rep (r :: TYPE rep). AnEquality s t a b -> ((s :~: a) -> (b :~: t) -> r) -> r Source #

A version of substEq that provides explicit, rather than implicit, equality evidence.

underEquality :: AnEquality s t a b -> p t s -> p b a Source #

The opposite of working overEquality is working underEquality.

overEquality :: AnEquality s t a b -> p a b -> p s t Source #

Recover a "profunctor lens" form of equality. Reverses fromLeibniz.

fromLeibniz :: (Identical a b a b -> Identical a b s t) -> Equality s t a b Source #

Convert a "profunctor lens" form of equality to an equality. Reverses overEquality.

The type should be understood as

fromLeibniz :: (forall p. p a b -> p s t) -> Equality s t a b

fromLeibniz' :: ((s :~: s) -> s :~: a) -> Equality' s a Source #

Convert Leibniz equality to equality. Reverses mapEq in Simple cases.

The type should be understood as

fromLeibniz' :: (forall f. f s -> f a) -> Equality' s a

cloneEquality :: AnEquality s t a b -> Equality s t a b Source #

# Implementation Details

data Identical a b s t where Source #

Provides witness that (s ~ a, b ~ t) holds.

Constructors

 Identical :: Identical a b a b