references-0.3.3.1: Selectors for reading and updating data.

Control.Reference.Operators

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 #

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

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