HORIZON HASKELLDocslts/ghc-10.0.x2b276322026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 2b27632 · 2026-10-31

Modulelens-family-2.1.3Haskell2010

Lens.Family2.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
  • Packagelens-family-2.1.3
  • Exports63
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceStock.hs

Stock Lenses

valueix :: Eq k => k -> Lens' (k -> v) v

Lens on a given point of a function.

Stock Prisms

Stock Grids

valuebend :: FiniteBits b => Grid' b Bool

A grid from the most significant bit to the least significant bit of a FiniteBits type.

Big endian order.

valuelend :: FiniteBits b => Grid' b Bool

A grid from the least significant bit to the most significant bit of a FiniteBits type.

Little endian order.

Stock Grates

valuebend' :: FiniteBits b => Grate' b Bool

A grate from the most significant bit to the least significant bit of a FiniteBits type.

Big endian order.

valuelend' :: FiniteBits b => Grate' b Bool

A grate from the least significant bit to the most significant bit of a FiniteBits type.

Little endian order.

Stock Traversals

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