lens-3.8.7.3: Lenses, Folds and Traversals

Portability | Rank2Types
Stability | provisional
Maintainer | Edward Kmett <ekmett@gmail.com>
Safe Haskell | Safe-Infered

Control.Lens.Equality

Contents

- Type Equality
- Implementation Details

Description

Synopsis

- type Equality s t a b = forall p f. p a (f b) -> p s (f t)
- type Equality' s a = Equality s s a a
- type AnEquality s t a b = Identical a (Mutator b) a (Mutator b) -> Identical a (Mutator b) s (Mutator t)
- type AnEquality' s a = AnEquality s s a a
- runEq :: AnEquality s t a b -> Identical s t a b
- substEq :: AnEquality s t a b -> ((s ~ a, t ~ b) => r) -> r
- mapEq :: AnEquality s t a b -> f s -> f a
- fromEq :: AnEquality s t a b -> Equality b a t s
- simply :: (Overloaded' p f s a -> r) -> Overloaded' p f s a -> r
- data Identical a b s t where
  - Identical :: Identical a b a b

# Type Equality

type Equality s t a b = forall p f. p a (f b) -> p s (f t)

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

Note: Composition with an `Equality` is index-preserving.

type Equality' s a = Equality s s a a

A `Simple` `Equality`.

type AnEquality s t a b = Identical a (Mutator b) a (Mutator b) -> Identical a (Mutator b) s (Mutator t)

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

type AnEquality' s a = AnEquality s s a a

A `Simple` `AnEquality`.

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

Extract a witness of type `Equality`.

substEq :: AnEquality s t a b -> ((s ~ a, t ~ b) => r) -> r

Substituting types with `Equality`.

mapEq :: AnEquality s t a b -> f s -> f a

We can use `Equality` to do substitution into anything.

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

`Equality` is symmetric.

simply :: (Overloaded' p f s a -> r) -> Overloaded' p f s a -> r

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.

# Implementation Details

data Identical a b s t where

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

Constructors

Identical :: Identical a b a b |