| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
RefExtras.LensRef
Synopsis
- data LensRef (r :: Type -> Type) a
- mkLensRef :: r z -> Lens' z a -> LensRef r a
- wholeLensRef :: r a -> LensRef r a
- zoomLensRef :: forall (r :: Type -> Type) a b. LensRef r a -> Lens' a b -> LensRef r b
- readLensRef :: forall m (r :: Type -> Type) a. (Functor m, ReadWriteRef r m) => LensRef r a -> m a
- writeLensRef :: forall (r :: Type -> Type) m a. ModifyRef r m => LensRef r a -> a -> m ()
- modifyLensRef :: forall (r :: Type -> Type) m a. ModifyRef r m => LensRef r a -> (a -> a) -> m ()
- atomicModifyLensRef :: forall (r :: Type -> Type) m a b. AtomicRef r m => LensRef r a -> (a -> (a, b)) -> m b
Documentation
data LensRef (r :: Type -> Type) a Source #
A reference focusing in on a part of a larger structure.
Instances
| (Functor m, AtomicRef r m) => AtomicRef (LensRef r) m Source # | |
Defined in RefExtras.LensRef Methods atomicModifyRef :: LensRef r a -> (a -> (a, b)) -> m b Source # | |
| (Functor m, ModifyRef r m) => ModifyRef (LensRef r) m Source # | |
Defined in RefExtras.LensRef | |
| (Functor m, ModifyRef r m) => ReadWriteRef (LensRef r) m Source # | |
wholeLensRef :: r a -> LensRef r a Source #
A trivial LensRef that focuses on the whole structure
zoomLensRef :: forall (r :: Type -> Type) a b. LensRef r a -> Lens' a b -> LensRef r b Source #
Zooms into a smaller part of the structure
readLensRef :: forall m (r :: Type -> Type) a. (Functor m, ReadWriteRef r m) => LensRef r a -> m a Source #
Read the reference through the lens.
writeLensRef :: forall (r :: Type -> Type) m a. ModifyRef r m => LensRef r a -> a -> m () Source #
Write the reference through the lens.
The ModifyRef constraint is necessary to ensure we read and write
the same structure!