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

Safe Haskell | Safe
Language | Haskell98

Data.Label.Poly

Contents

- The polymorphic Lens type.

Description

Lenses that allow polymorphic updates.

Synopsis

- data Lens cat f o
- lens :: cat f o -> cat (cat o i, f) g -> Lens cat (f -> g) (o -> i)
- point :: Point cat g i f o -> Lens cat (f -> g) (o -> i)
- get :: Lens cat (f -> g) (o -> i) -> cat f o
- modify :: Lens cat (f -> g) (o -> i) -> cat (cat o i, f) g
- set :: Arrow arr => Lens arr (f -> g) (o -> i) -> arr (i, f) g
- iso :: ArrowApply cat => Iso cat f o -> Iso cat g i -> Lens cat (f -> g) (o -> i)
- (>-) :: Arrow arr => Lens arr (j -> a) (i -> b) -> Lens arr (f -> g) (o -> i) -> Point arr g j f o
- for :: Arrow arr => Lens arr (j -> a) (i -> b) -> Lens arr (f -> g) (o -> i) -> Point arr g j f o

# The polymorphic Lens type.

data Lens cat f o Source #

Abstract polymorphic lens datatype. The getter and setter functions work in some category. Categories allow for effectful lenses, for example, lenses that might fail or use state.

Instances

ArrowApply arr => Category (Lens arr :: Type -> Type -> Type) Source # | Category instance for monomorphic lenses.
Instance details Defined in Data.Label.Poly Methods id :: Lens arr a a Source # (.) :: Lens arr b c -> Lens arr a b -> Lens arr a c Source #

lens Source #

Arguments

:: cat f o | Getter.
-> cat (cat o i, f) g | Modifier.
-> Lens cat (f -> g) (o -> i) |

Create a lens out of a getter and setter.

point :: Point cat g i f o -> Lens cat (f -> g) (o -> i) Source #

Create lens from a `Point`.

get :: Lens cat (f -> g) (o -> i) -> cat f o Source #

Get the getter arrow from a lens.

modify :: Lens cat (f -> g) (o -> i) -> cat (cat o i, f) g Source #

Get the modifier arrow from a lens.

set :: Arrow arr => Lens arr (f -> g) (o -> i) -> arr (i, f) g Source #

Get the setter arrow from a lens.

iso :: ArrowApply cat => Iso cat f o -> Iso cat g i -> Lens cat (f -> g) (o -> i) Source #

Lift a polymorphic isomorphism into a `Lens`.

The isomorphism needs to be passed in twice to properly unify.

(>-) :: Arrow arr => Lens arr (j -> a) (i -> b) -> Lens arr (f -> g) (o -> i) -> Point arr g j f o infix 7 Source #

Make a Lens output diverge by changing the input of the modifier. The operator can be read as points-to.

for :: Arrow arr => Lens arr (j -> a) (i -> b) -> Lens arr (f -> g) (o -> i) -> Point arr g j f o infix 7 Source #

Non-operator version of `>-`, since it clashes with an operator when the Arrows language extension is used.