lens-4.17: Lenses, Folds and Traversals

Copyright(C) 2012-16 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellSafe





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 #

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.

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

Extract a witness of type Equality.

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

Substituting types with Equality.

mapEq :: forall (s :: k1) (t :: k2) (a :: k1) (b :: k2) (f :: k1 -> *). 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 :: (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

simple :: Equality' a a Source #

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.

Implementation Details

data Identical a b s t where Source #

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


Identical :: Identical a b a b