optics-extra-0.4.2.1: Extra utilities and instances for optics-core
Safe HaskellNone
LanguageHaskell2010

Optics.State.Operators

Description

Defines infix operators for the operations in Optics.State. These operators are not exposed by the main Optics module, but must be imported explicitly.

Synopsis

State modifying optics

(.=) :: (Is k A_Setter, MonadState s m) => Optic k is s s a b -> b -> m () infix 4 Source #

Replace the target(s) of an Optic in our monadic state with a new value, irrespective of the old.

This is an infix version of assign.

(?=) :: (Is k A_Setter, MonadState s m) => Optic k is s s (Maybe a) (Maybe b) -> b -> m () infix 4 Source #

Replace the target(s) of an Optic in our monadic state with Just a new value, irrespective of the old.

(%=) :: (Is k A_Setter, MonadState s m) => Optic k is s s a b -> (a -> b) -> m () infix 4 Source #

Map over the target(s) of an Optic in our monadic state.

This is an infix version of modifying.

State modifying optics with passthrough

(%%=) :: (PermeableOptic k r, MonadState s m) => Optic k is s s a b -> (a -> (r, b)) -> m (ViewResult k r) infix 4 Source #

Modify the target of an PermeableOptic in the current state returning some extra information of type depending on the optic (r, Maybe r or monoidal summary).

Returning new value

(<.=) :: (PermeableOptic k b, MonadState s m) => Optic k is s s a b -> b -> m (ViewResult k b) infix 4 Source #

Set with pass-through.

This is useful for chaining assignment without round-tripping through your Monad stack.

(<?=) :: (PermeableOptic k (Maybe b), MonadState s m) => Optic k is s s (Maybe a) (Maybe b) -> b -> m (ViewResult k (Maybe b)) infix 4 Source #

Set Just a value with pass-through.

This is useful for chaining assignment without round-tripping through your Monad stack.

(<%=) :: (PermeableOptic k b, MonadState s m) => Optic k is s s a b -> (a -> b) -> m (ViewResult k b) infix 4 Source #

Modify the target of a PermeableOptic into your Monad's state by a user supplied function and return the result.

Returning old value

(<<.=) :: (PermeableOptic k a, MonadState s m) => Optic k is s s a b -> b -> m (ViewResult k a) infix 4 Source #

Replace the target of a PermeableOptic into your Monad's state with a user supplied value and return the old value that was replaced.

(<<?=) :: (PermeableOptic k (Maybe a), MonadState s m) => Optic k is s s (Maybe a) (Maybe b) -> b -> m (ViewResult k (Maybe a)) infix 4 Source #

Replace the target of a PermeableOptic into your Monad's state with Just a user supplied value and return the old value that was replaced.

(<<%=) :: (PermeableOptic k a, MonadState s m) => Optic k is s s a b -> (a -> b) -> m (ViewResult k a) infix 4 Source #

Modify the target of a PermeableOptic into your Monad's state by a user supplied function and return the old value that was replaced.

Passthrough

class (Is k A_Traversal, ViewableOptic k r) => PermeableOptic k r where Source #

Methods

passthrough :: Optic k is s t a b -> (a -> (r, b)) -> s -> (ViewResult k r, t) Source #

Modify the target of an Optic returning extra information of type r.

Instances

Instances details
PermeableOptic An_Iso r Source # 
Instance details

Defined in Optics.Passthrough

Methods

passthrough :: forall (is :: IxList) s t a b. Optic An_Iso is s t a b -> (a -> (r, b)) -> s -> (ViewResult An_Iso r, t) Source #

PermeableOptic A_Lens r Source # 
Instance details

Defined in Optics.Passthrough

Methods

passthrough :: forall (is :: IxList) s t a b. Optic A_Lens is s t a b -> (a -> (r, b)) -> s -> (ViewResult A_Lens r, t) Source #

PermeableOptic A_Prism r Source # 
Instance details

Defined in Optics.Passthrough

Methods

passthrough :: forall (is :: IxList) s t a b. Optic A_Prism is s t a b -> (a -> (r, b)) -> s -> (ViewResult A_Prism r, t) Source #

PermeableOptic An_AffineTraversal r Source # 
Instance details

Defined in Optics.Passthrough

Methods

passthrough :: forall (is :: IxList) s t a b. Optic An_AffineTraversal is s t a b -> (a -> (r, b)) -> s -> (ViewResult An_AffineTraversal r, t) Source #

Monoid r => PermeableOptic A_Traversal r Source # 
Instance details

Defined in Optics.Passthrough

Methods

passthrough :: forall (is :: IxList) s t a b. Optic A_Traversal is s t a b -> (a -> (r, b)) -> s -> (ViewResult A_Traversal r, t) Source #