| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Effectful.Labeled.State
Synopsis
- data State s :: Effect where
- runStateLocal :: forall label s es a. HasCallStack => s -> Eff (Labeled label (State s) : es) a -> Eff es (a, s)
- evalStateLocal :: forall label s es a. HasCallStack => s -> Eff (Labeled label (State s) : es) a -> Eff es a
- execStateLocal :: forall label s es a. HasCallStack => s -> Eff (Labeled label (State s) : es) a -> Eff es s
- runStateShared :: forall label s es a. HasCallStack => s -> Eff (Labeled label (State s) : es) a -> Eff es (a, s)
- evalStateShared :: forall label s es a. HasCallStack => s -> Eff (Labeled label (State s) : es) a -> Eff es a
- execStateShared :: forall label s es a. HasCallStack => s -> Eff (Labeled label (State s) : es) a -> Eff es s
- get :: forall label s es. (HasCallStack, Labeled label (State s) :> es) => Eff es s
- gets :: forall label s es a. (HasCallStack, Labeled label (State s) :> es) => (s -> a) -> Eff es a
- put :: forall label s es. (HasCallStack, Labeled label (State s) :> es) => s -> Eff es ()
- state :: forall label s es a. (HasCallStack, Labeled label (State s) :> es) => (s -> (a, s)) -> Eff es a
- modify :: forall label s es. (HasCallStack, Labeled label (State s) :> es) => (s -> s) -> Eff es ()
- stateM :: forall label s es a. (HasCallStack, Labeled label (State s) :> es) => (s -> Eff es (a, s)) -> Eff es a
- modifyM :: forall label s es. (HasCallStack, Labeled label (State s) :> es) => (s -> Eff es s) -> Eff es ()
- newtype Labeled (label :: k) (e :: Effect) :: Effect where
Effect
data State s :: Effect where Source #
Provide access to a mutable value of type s.
Constructors
| Get :: State s m s | |
| Put :: s -> State s m () | |
| State :: (s -> (a, s)) -> State s m a | |
| StateM :: (s -> m (a, s)) -> State s m a | Deprecated: Use a combination of Get and Put instead. |
Instances
| type DispatchOf (State s) Source # | |
Defined in Effectful.Internal.Effect.Dynamic | |
Handlers
Local
Arguments
| :: forall label s es a. HasCallStack | |
| => s | The initial state. |
| -> Eff (Labeled label (State s) : es) a | |
| -> Eff es (a, s) |
Run the State effect with the given initial state and return the final
value along with the final state (via Effectful.State.Static.Local).
Arguments
| :: forall label s es a. HasCallStack | |
| => s | The initial state. |
| -> Eff (Labeled label (State s) : es) a | |
| -> Eff es a |
Run the State effect with the given initial state and return the final
value, discarding the final state (via Effectful.State.Static.Local).
Arguments
| :: forall label s es a. HasCallStack | |
| => s | The initial state. |
| -> Eff (Labeled label (State s) : es) a | |
| -> Eff es s |
Run the State effect with the given initial state and return the final
state, discarding the final value (via Effectful.State.Static.Local).
Shared
Arguments
| :: forall label s es a. HasCallStack | |
| => s | The initial state. |
| -> Eff (Labeled label (State s) : es) a | |
| -> Eff es (a, s) |
Run the State effect with the given initial state and return the final
value along with the final state (via Effectful.State.Static.Shared).
Arguments
| :: forall label s es a. HasCallStack | |
| => s | The initial state. |
| -> Eff (Labeled label (State s) : es) a | |
| -> Eff es a |
Run the State effect with the given initial state and return the final
value, discarding the final state (via Effectful.State.Static.Shared).
Arguments
| :: forall label s es a. HasCallStack | |
| => s | The initial state. |
| -> Eff (Labeled label (State s) : es) a | |
| -> Eff es s |
Run the State effect with the given initial state and return the final
state, discarding the final value (via Effectful.State.Static.Shared).
Operations
get :: forall label s es. (HasCallStack, Labeled label (State s) :> es) => Eff es s Source #
Fetch the current value of the state.
Arguments
| :: forall label s es a. (HasCallStack, Labeled label (State s) :> es) | |
| => (s -> a) | . |
| -> Eff es a |
Arguments
| :: forall label s es. (HasCallStack, Labeled label (State s) :> es) | |
| => s | . |
| -> Eff es () |
Set the current state to the given value.
Arguments
| :: forall label s es a. (HasCallStack, Labeled label (State s) :> es) | |
| => (s -> (a, s)) | . |
| -> Eff es a |
Apply the function to the current state and return a value.
Arguments
| :: forall label s es. (HasCallStack, Labeled label (State s) :> es) | |
| => (s -> s) | . |
| -> Eff es () |
Arguments
| :: forall label s es a. (HasCallStack, Labeled label (State s) :> es) | |
| => (s -> Eff es (a, s)) | . |
| -> Eff es a |
Deprecated: Use a combination of get and put instead.
Apply the monadic function to the current state and return a value.
Re-exports
newtype Labeled (label :: k) (e :: Effect) :: Effect where Source #
Assign a label to an effect.
Note: labeled effects are best used together with the effectful-plugin package, as it significantly improves their usability.
The constructor is for sending labeled operations of a dynamically dispatched effect to the handler:
>>>import Effectful.Dispatch.Dynamic
>>>:{data X :: Effect where X :: X m Int type instance DispatchOf X = Dynamic :}
>>>:{runPureEff . runLabeled @"x" (interpret_ $ \X -> pure 333) $ do send $ Labeled @"x" X :} 333
Instances
| type DispatchOf (Labeled label e) Source # | |
Defined in Effectful.Labeled | |
| data StaticRep (Labeled label e) Source # | |
Defined in Effectful.Labeled | |