Map over the target(s) of an Optic in our monadic state.
execState (do modifying _1 (*10); modifying _2 $ stimes 5) (6,"o")(60,"ooooo")
execState (modifying each $ stimes 2) ("a","b")("aa","bb")
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Moduleoptics-extra-0.4.2.1Haskell2010
This module contains utilities for working with Setters in a MonadState context. If you prefer operator versions, you may wish to import Optics.State.Operators.
Map over the target(s) of an Optic in our monadic state.
execState (do modifying _1 (*10); modifying _2 $ stimes 5) (6,"o")(60,"ooooo")
execState (modifying each $ stimes 2) ("a","b")("aa","bb")
Version of modifying that is strict in both optic application and state modification.
flip evalState ('a','b') $ modifying _1 (errorWithoutStackTrace "oops")()
flip evalState ('a','b') $ modifying' _1 (errorWithoutStackTrace "oops")*** Exception: oops
Replace the target(s) of an Optic in our monadic state with a new value, irrespective of the old.
execState (do assign _1 'c'; assign _2 'd') ('a','b')('c','d')
execState (assign each 'c') ('a','b')('c','c')
Version of assign that is strict in both optic application and state modification.
flip evalState ('a','b') $ assign _1 (errorWithoutStackTrace "oops")()
flip evalState ('a','b') $ assign' _1 (errorWithoutStackTrace "oops")*** Exception: oops
Use the target of a AffineTraveral or AffineFold in the current state.
evalState (preuse $ _1 % _Right) (Right 'a','b')Just 'a'