fclabels-2.0: First class accessor labels implemented as lenses.

Safe HaskellSafe-Inferred

Data.Label.Total

Description

Default lenses for simple total getters and monomorphic updates. Useful for creating accessor labels for single constructor datatypes. Also useful field labels that are shared between all the constructors of a multi constructor datatypes.

Synopsis

Documentation

type :-> f o = Lens Total f oSource

Total lens type specialized for total accessor functions.

type Total = (->)Source

Context that represents computations that always produce an output.

lensSource

Arguments

:: (f -> o)

Getter.

-> ((o -> i) -> f -> g)

Modifier.

-> (f -> g) :-> (o -> i) 

Create a total lens from a getter and a modifier.

We expect the following law to hold:

 get l (set l a f) == a
 set l (get l f) f == f

get :: ((f -> g) :-> (o -> i)) -> f -> oSource

Get the getter function from a lens.

modify :: ((f -> g) :-> (o -> i)) -> (o -> i) -> f -> gSource

Get the modifier function from a lens.

set :: ((f -> g) :-> (o -> i)) -> i -> f -> gSource

Get the setter function from a lens.