vinyl-0.3: Extensible Records

Safe HaskellNone

Data.Vinyl.Lens

Description

A small, en passant lens implementation to provide accessors for record fields. Lenses produced with rLens are fully compatible with the lens package.

Synopsis

Documentation

rGet' :: IElem (sy ::: t) rs => (sy ::: t) -> Rec rs f -> f tSource

Project a field from a Rec.

rGet :: IElem (sy ::: t) rs => (sy ::: t) -> PlainRec rs -> tSource

Project a field from a PlainRec.

rPut' :: IElem (sy ::: t) rs => (sy ::: t) -> f t -> Rec rs f -> Rec rs fSource

Set a field in a Rec over an arbitrary functor.

rPut :: IElem (sy ::: t) rs => (sy ::: t) -> t -> PlainRec rs -> PlainRec rsSource

Set a field in a PlainRec.

rMod :: (IElem (sy ::: t) rs, Functor f) => (sy ::: t) -> (t -> t) -> Rec rs f -> Rec rs fSource

Modify a field.

rLens' :: forall r rs sy t f g. (r ~ (sy ::: t), IElem r rs, Functor g) => r -> (f t -> g (f t)) -> Rec rs f -> g (Rec rs f)Source

Provide a lens to a record field. Note that this implementation does not support polymorphic update. In the parlance of the lens package,

 rLens' :: IElem (sy:::t) rs => (sy:::t) -> Lens' (Rec rs f) (f t)

rLens :: forall r rs sy t g. (r ~ (sy ::: t), IElem r rs, Functor g) => r -> (t -> g t) -> PlainRec rs -> g (PlainRec rs)Source

A lens into a PlainRec that smoothly interoperates with lenses from the lens package. Note that polymorphic update is not supported. In the parlance of the lens package,

 rLens :: IElem (sy:::t) rs => (sy:::t) -> Lens' (PlainRec rs) t