references-0.1.0.0: Generalization of lenses, folds and traversals for haskell

Safe HaskellSafe-Inferred
LanguageHaskell98

Control.Reference.Operators

Description

Common operators for references

Synopsis

Documentation

(^.) :: s -> Reference wm Identity s t a b -> a infixl 4 Source

Gets the referenced data

(^?) :: s -> Reference wm rm s t a b -> rm a infixl 4 Source

Gets the referenced data in the reader monad of the lens

(.~) :: Reference Identity rm s t a b -> b -> s -> t infixl 4 Source

Sets the referenced data (for lenses with identity writer)

(.=) :: Monad rw => Reference rw rm s t a b -> b -> s -> rw t infixl 4 Source

Sets the referenced data in the writer monad of the lens

(%~) :: Reference Identity rm s t a b -> (a -> b) -> s -> t infixl 4 Source

Applies the given function on the referenced data (for lenses with identity writer)

(%~=) :: Monad rw => Reference rw rm s t a b -> (a -> b) -> s -> rw t infixl 4 Source

Applies the given monadic function on the referenced data in the monad of the lens

(%=) :: Reference rw rm s t a b -> (a -> rw b) -> s -> rw t infixl 4 Source

Applies the given monadic function on the referenced data in the monad of the lens

(%!) :: Monad rw => Reference rw rm s s a a -> (a -> rw c) -> s -> rw s Source

Performs the given monadic action on referenced data

(&) :: forall w r1 r2 s t c d a b. MonadCompose r1 r2 => Reference w r1 s t c d -> Reference w r2 c d a b -> Reference w (ResultMonad r1 r2) s t a b infixl 6 Source

Composes two references. The two references should have the same writer semantics and their reader semantics must be composable with MonadCompose.

(&+&) :: forall w r1 r2 r12 r3 a s. (Monad w, MonadPlus r3, MonadCompose r1 r2, r12 ~ ResultMonad r1 r2, MonadCompose r12 [], r3 ~ ResultMonad r12 []) => Reference w r1 s s a a -> Reference w r2 s s a a -> Reference w r3 s s a a infixl 5 Source

Adds two references. The references must be monomorphic, because setter needs to change the object twice.