Safe Haskell | None |
---|---|

Language | Haskell98 |

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`

).

- (^.) :: s -> Getter Identity s t a b -> a
- (^?) :: Monad m => s -> Getter m s t a b -> m a
- review :: Reference MU MU MU Identity s s a a -> a -> s
- (.=) :: Setter Identity s t a b -> b -> s -> t
- (!=) :: Setter m s t a b -> b -> s -> m t
- (.~) :: Setter Identity s t a b -> (a -> Identity b) -> s -> t
- (!~) :: Setter m s t a b -> (a -> m b) -> s -> m t
- (.-) :: Setter Identity s t a b -> (a -> b) -> s -> t
- (!-) :: Monad m => Setter m s t a b -> (a -> b) -> s -> m t
- (!|) :: Monad m => Setter m s s a a -> (a -> m c) -> s -> m s

# Getters

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

# Updaters

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

Monadic updater with a pure result

# 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