HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulelens-family-core-2.1.3Haskell2010

Lens.Family.Stock

This module contains lenses, prisms, grids, grates and traversals for common structures in Haskell. It also contains the combinators for various kinds of optics.

A Function name with ' is a grate variant of a grid, and a function name with _ is a traversal variants of a grid or prism. For example, both' is the grate variant of both while both_ is the traversal variant.

Contents
  1. Stock Lenses
  2. Stock Prisms
  3. Stock Grids
  4. Stock Grates
  5. Stock Traversals
  6. Stock SECs
  7. Lens Combinators
  8. Types
  9. Re-exports
  10. Deprecated names
Synopsis

Stock Lenses

value_1 :: Functor f => LensLike f (a, r) (b, r) a b
_1 :: Lens (a, r) (b, r) a b

Lens on the first element of a pair.

value_2 :: Functor f => LensLike f (r, a) (r, b) a b
_2 :: Lens (r, a) (r, b) a b

Lens on the second element of a pair.

valueix :: (Eq k, Functor f) => k -> LensLike' f (k -> v) v
ix :: Eq k => k -> Lens' (k -> v) v

Lens on a given point of a function.

Stock Prisms

Stock Grids

Stock Grates

valuecod :: Functor g => GrateLike g (r -> a) (r -> b) a b
cod :: Grate (r -> a) (r -> b) a b

A grate accessing the codomain of a function.

valueboth' :: Functor g => GrateLike g (a, a) (b, b) a b
both' :: Grate (a,a) (b,b) a b

A grate on both elements of a pair (a,a).

both' = over both

Stock Traversals

valueboth_ :: Applicative f => LensLike f (a, a) (b, b) a b
both_ :: Traversal (a,a) (b,b) a b

Traversals on both elements of a pair (a,a).

both_ = under both

Stock SECs

Lens Combinators

valuealongside
  1. :: Functor f
  2. => LensLike (AlongsideLeft f b1) s0 t0 a0 b0
  3. -> LensLike (AlongsideRight f t0) s1 t1 a1 b1
  4. -> LensLike f (s0, s1) (t0, t1) (a0, a1) (b0, b1)
alongside :: Lens s0 t0 a0 b0 -> Lens s1 t1 a1 b1 -> Lens (s0, s1) (t0, t1) (a0, a1) (b0, b1)
alongside :: Getter s0 t0 a0 b0 -> Getter s1 t1 a1 b1 -> Getter (s0, s1) (t0, t1) (a0, a1) (b0, b1)

Given two lens/getter families, make a new lens/getter on their product.

valuebackwards :: LensLike (Backwards f) s t a b -> LensLike f s t a b
backwards :: Traversal s t a b -> Traversal s t a b
backwards :: Fold s t a b -> Fold s t a b

Given a traversal or fold, reverse the order that elements are traversed.

backwards :: Lens s t a b -> Lens s t a b
backwards :: Getter s t a b -> Getter s t a b
backwards :: Setter s t a b -> Setter s t a b

No effect on lenses, getters or setters.

valuebeside'
  1. :: Functor g
  2. => GrateLike g s0 t0 a b
  3. -> GrateLike g s1 t1 a b
  4. -> GrateLike g (s0, s1) (t0, t1) a b
beside' :: Grate s0 t0 a b -> Grate s1 t1 a b -> Grate (s0, s1) (t0, t1) a b
beside' :: Resetter s0 t0 a b -> Resetter s1 t1 a b -> Resetter (s0, s1) (t0, t1) a b

Given two grates/resetters referencing a type c, create a grate/resetter on the pair referencing c.

valuebeside_
  1. :: Applicative f
  2. => LensLike f s0 t0 a b
  3. -> LensLike f s1 t1 a b
  4. -> LensLike f (s0, s1) (t0, t1) a b
beside_ :: Traversal s0 t0 a b -> Traversal s1 t1 a b -> Traversal (s0, s1) (t0, t1) a b
beside_ :: Fold s0 t0 a b -> Fold s1 t1 a b -> Fold (s0, s1) (t0, t1) a b
beside_ :: Setter s0 t0 a b -> Setter s1 t1 a b -> Setter (s0, s1) (t0, t1) a b

Given two traversals/folds/setters referencing a type c, create a traversal/fold/setter on the pair referencing c.

valuechoosing
  1. :: Functor f
  2. => LensLike f s0 t0 a b
  3. -> LensLike f s1 t1 a b
  4. -> LensLike f (Either s0 s1) (Either t0 t1) a b
choosing :: Lens s0 t0 a b -> Lens s1 t1 a b -> Lens (Either s0 s1) (Either t0 t1) a b
choosing :: Traversal s0 t0 a b -> Traversal s1 t1 a b -> Traversal (Either s0 s1) (Either t0 t1) a b
choosing :: Getter s0 t0 a b -> Getter s1 t1 a b -> Getter (Either s0 s1) (Either t0 t1) a b
choosing :: Fold s0 t0 a b -> Fold s1 t1 a b -> Fold (Either s0 s1) (Either t0 t1) a b
choosing :: Setter s0 t0 a b -> Setter s1 t1 a b -> Setter (Either s0 s1) (Either t0 t1) a b

Given two lens/traversal/getter/fold/setter families with the same substructure, make a new lens/traversal/getter/fold/setter on Either.

valuefrom
  1. :: (Functor f, Functor g)
  2. => AdapterLike (FromF (g s -> f t) (f b) g) (FromG (f b) f) b a t s
  3. -> AdapterLike f g s t a b
from :: Adapter b a t s -> Adapter s t a b

Reverses the direction of an adapter.

from :: Getter b a t s -> Reviewer s t a b
from :: Reviewer b a t s -> Getter s t a b

Changes a Getter into a Reviewer and vice versa.

Types

Re-exports

newtypenewtype Backwards (f :: k -> Type) (a :: k)

The same functor, but with an Applicative instance that performs actions in the reverse order.

Instances21Generic1, Functor, Applicative, Foldable, Traversable, Alternative, …
classclass Bits b => FiniteBits b where

The FiniteBits class denotes types with a finite, fixed number of bits.

Instances63FiniteBits, …

Deprecated names