fused-effects-optics-0.2.0.0: Bridge between the optics and fused-effects ecosystems.
Safe HaskellNone
LanguageHaskell2010

Control.Effect.Optics

Synopsis

Reader operations

view :: forall r a m sig k is. (Is k A_Getter, Has (Reader r) sig m) => Optic' k is r a -> m a Source #

View the target of a Lens, Iso, or Getter in the current context.

Because functions implement Reader, you can use this wherever you would use the view function in optics, as well as the gview operation in optics-extra.

views :: forall r a b m sig k is. (Is k A_Getter, Has (Reader r) sig m) => Optic' k is r a -> (a -> b) -> m b Source #

Apply a function to the target of a Lens, Iso, or Getter in the current context.

locally :: (Is k A_Setter, Has (Reader r) sig m) => Optic k is r r a b -> (a -> b) -> m c -> m c Source #

Given a monadic argument, evaluate it in a context modified by applying the provided function to the target of the provided Setter, Lens, or Traversal.

State operations

use :: forall s a m sig k is. (Is k A_Getter, Has (State s) sig m) => Optic' k is s a -> m a Source #

Use the target of a Lens, Iso, or Getter in the current state.

uses :: forall s a b m sig k is. (Is k A_Getter, Has (State s) sig m) => Optic' k is s a -> (a -> b) -> m b Source #

Apply a function to the target of a Lens, Iso, or Getter in the current state.

preuse :: forall s a m sig k is. (Is k An_AffineFold, Has (State s) sig m) => Optic' k is s a -> m (Maybe a) Source #

Use the target of a AffineTraversal or AffineFold in the current state.

assign :: forall s a b m sig k is. (Is k A_Setter, Has (State s) sig m) => Optic k is s s a b -> b -> m () Source #

Replace the target(s) of an Optic in our monadic state with a new value, irrespective of the old. The action and the optic operation are applied strictly.

This is aprefix form of .=.

modifying :: (Is k A_Setter, Has (State s) sig m) => Optic k is s s a b -> (a -> b) -> m () Source #

Map over the target(s) of an Optic in our monadic state. The action and the optic operation are applied strictly.

Infix operators

(.=) :: forall s a b m sig k is. (Is k A_Setter, Has (State s) sig 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. The action and the optic operation are applied strictly.

This is an infix form of assign.

(?=) :: forall s a b m sig k is. (Is k A_Setter, Has (State s) sig m) => Optic k is s s 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. The action and the optic operation are applied strictly.

(%=) :: (Is k A_Setter, Has (State s) sig 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. The action and the optic operation are applied strictly.