mini-1.3.0.1: Minimal essentials
Safe HaskellSafe-Inferred
LanguageHaskell2010

Mini.Optics.Lens

Description

Compose polymorphic record updates with van Laarhoven lenses

Synopsis
  • type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
  • lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
  • view :: Lens s t a b -> s -> a
  • over :: Lens s t a b -> (a -> b) -> s -> t
  • set :: Lens s t a b -> b -> s -> t

Type

type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t Source #

A reference updating structures from s to t and fields from a to b

Construction

lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b Source #

Make a lens from a getter and a setter

Operations

view :: Lens s t a b -> s -> a Source #

Fetch the field referenced by a lens from a structure

over :: Lens s t a b -> (a -> b) -> s -> t Source #

Update the field referenced by a lens with an operation on a structure

set :: Lens s t a b -> b -> s -> t Source #

Overwrite the field referenced by a lens with a value on a structure