record-0.3.2: First class records implemented with quasi-quotation

Safe HaskellNone
LanguageHaskell2010

Record.Lens

Description

A minimal subset of the "lens" library functionality, which is completely compatible with it.

Unless you use the "lens" library itself, this module is your interface to manipulating the record fields.

Synopsis

Documentation

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

A reference from a datastructure s to its some part a, which can be used to manipulate that particular part. It is possible to change the part to another type a' during updates. In such case the whole datastructure will change the type to s' as well.

view :: Lens s s' a a' -> s -> a Source #

Given a lens to a subpart and a datastructure, produce the value of the referred subpart.

set :: Lens s s' a a' -> a' -> s -> s' Source #

Given a lens to a subpart, a new value for it and a datastructure, produce an updated datastructure.

over :: Lens s s' a a' -> (a -> a') -> s -> s' Source #

Given a lens to a subpart, and an update function for it, produce a function, which updates the datastructure.