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

Safe HaskellSafe-Inferred

Data.Label.Total

Contents

Description

Default lenses for simple total getters and total possibly polymorphic, 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.

Working in contexts.

traverse :: Functor m => ((f -> g) :-> (o -> i)) -> (o -> m i) -> f -> m gSource

Modify in some context.

lifted :: Monad m => ((f -> g) :-> (m o -> m i)) -> ((o -> i) :-> (m a -> m b)) -> (f -> g) :-> (m a -> m b)Source

Lifted lens composition.

For example, useful when specialized to lists:

 :: (f :-> [o])
 -> (o :-> [a])
 -> (f :-> [a])