Support for access to a shared, mutable value of a particular type.
The value is shared between multiple threads. If you want each thread to
manage its own version of the value, use Effectful.State.Static.Local.
Note: unlike the Control.Monad.Trans.State.StateT monad transformer from
the transformers library, the State effect doesn't discard state updates
when an exception is received:
Example3 expressions
>>> import Control.Exception (ErrorCall)>>> import Control.Monad.Catch>>> import Control.Monad.Trans.State.Strict qualified as S
Example1 expression
>>> :{ (`S.execStateT` "Hi") . handle (\(_::ErrorCall) -> pure ()) $ do S.modify (++ " there!") error "oops":}"Hi"
Deprecated. Operations of the same State effect used within the callback deadlock. Use a combination of get and put instead, or an explicit MVar if you need atomic updates.
Apply the monadic function to the current state and return a value.
Note: this function gets an exclusive access to the state for its duration.
Deprecated. Operations of the same State effect used within the callback deadlock. Use a combination of get and put instead, or an explicit MVar if you need atomic updates.