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

Safe HaskellSafe
LanguageHaskell98

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 o Source

Total lens type specialized for total accessor functions.

type Total = (->) Source

Context that represents computations that always produce an output.

lens Source

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 -> o Source

Get the getter function from a lens.

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

Get the modifier function from a lens.

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

Get the setter function from a lens.

Working in contexts.

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

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])