references-0.3.2.2: Selectors for reading and updating data.

Safe HaskellSafe
LanguageHaskell98

Control.Reference.Operators

Contents

Description

Common operators for using references.

There are four kinds of operator for every type of reference. The operators are either getters (^. and ^?), setters (.= and !=), monadic updaters (.~ and !~), pure updaters (.- and !-) or action performers (!|).

The former operators (with the dot) are pure operators, the later are monadic operators. For example, (1,2) ^. _1 results in a pure numeric value, while Right 4 ^? right produces Just 4 (or a higher level value representing Just 4).

Synopsis

Getters

(^.) :: s -> Getter Identity s t a b -> a infixl 4 Source #

Pure getter operator

(^?) :: Monad m => s -> Getter m s t a b -> m a infixl 4 Source #

Generic getter operator

review :: Reference MU MU MU Identity s s a a -> a -> s Source #

Gets the context from the referenced element by turning the reference.

Setters

(.=) :: Setter Identity s t a b -> b -> s -> t infixl 4 Source #

Pure setter function

(!=) :: Setter m s t a b -> b -> s -> m t infixl 4 Source #

Monadic setter function

Updaters

(.~) :: Setter Identity s t a b -> (a -> Identity b) -> s -> t infixl 4 Source #

Monadic updater with a pure result

(!~) :: Setter m s t a b -> (a -> m b) -> s -> m t infixl 4 Source #

Monadic updater

Updaters with pure function inside

(.-) :: Setter Identity s t a b -> (a -> b) -> s -> t infixl 4 Source #

Pure updater with pure function

(!-) :: Monad m => Setter m s t a b -> (a -> b) -> s -> m t infixl 4 Source #

Monadic update with pure function

Updaters with only side-effects

(!|) :: Monad m => Setter m s s a a -> (a -> m c) -> s -> m s infixl 4 Source #

Perform a given action monadically