ref-extras-0.2.0: Extra stuff for mutable references
Safe HaskellNone
LanguageHaskell2010

RefExtras.LensRef

Synopsis

Documentation

data LensRef (r :: Type -> Type) a Source #

A reference focusing in on a part of a larger structure.

Instances

Instances details
(Functor m, AtomicRef r m) => AtomicRef (LensRef r) m Source # 
Instance details

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 # 
Instance details

Defined in RefExtras.LensRef

Methods

modifyRef :: LensRef r a -> (a -> a) -> m () Source #

(Functor m, ModifyRef r m) => ReadWriteRef (LensRef r) m Source # 
Instance details

Defined in RefExtras.LensRef

Methods

readRef :: LensRef r a -> m a Source #

writeRef :: LensRef r a -> a -> m () Source #

mkLensRef :: r z -> Lens' z a -> LensRef r a Source #

LensRef constructor

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!

modifyLensRef :: forall (r :: Type -> Type) m a. ModifyRef r m => LensRef r a -> (a -> a) -> m () Source #

Modify the reference through the lens.

atomicModifyLensRef :: forall (r :: Type -> Type) m a b. AtomicRef r m => LensRef r a -> (a -> (a, b)) -> m b Source #

Atomically modify the reference through the lens.