| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Effect.Interpret
Synopsis
- runInterpret :: (forall x. eff m (m x) -> m x) -> InterpretC eff m a -> m a
- newtype InterpretC eff m a = InterpretC {
- runInterpretC :: ReaderC (Handler eff m) m a
- runInterpretState :: (forall x. s -> eff (StateC s m) (StateC s m x) -> m (s, x)) -> s -> InterpretStateC eff s m a -> m (s, a)
- newtype InterpretStateC eff s m a = InterpretStateC {
- runInterpretStateC :: ReaderC (HandlerState eff s m) (StateC s m) a
Documentation
runInterpret :: (forall x. eff m (m x) -> m x) -> InterpretC eff m a -> m a Source #
Interpret an effect using a higher-order function.
This involves a great deal less boilerplate than defining a custom Carrier instance, at the expense of somewhat less performance. It’s a reasonable starting point for new interpretations, and if more performance or flexibility is required, it’s straightforward to “graduate” by replacing the relevant runInterpret handlers with specialized Carrier instances for the effects.
At time of writing, a simple passthrough use of runInterpret to handle a State effect is about five times slower than using StateC directly.
run (runInterpret (\ op -> case op of { Get k -> k a ; Put _ k -> k }) get) == anewtype InterpretC eff m a Source #
Constructors
| InterpretC | |
Fields
| |
Instances
runInterpretState :: (forall x. s -> eff (StateC s m) (StateC s m x) -> m (s, x)) -> s -> InterpretStateC eff s m a -> m (s, a) Source #
Interpret an effect using a higher-order function with some state variable.
This involves a great deal less boilerplate than defining a custom Carrier instance, at the expense of somewhat less performance. It’s a reasonable starting point for new interpretations, and if more performance or flexibility is required, it’s straightforward to “graduate” by replacing the relevant runInterpretState handlers with specialized Carrier instances for the effects.
At time of writing, a simple use of runInterpretState to handle a State effect is about four times slower than using StateC directly.
run (runInterpretState (\ s op -> case op of { Get k -> runState s (k s) ; Put s' k -> runState s' k }) a get) == anewtype InterpretStateC eff s m a Source #
Constructors
| InterpretStateC | |
Fields
| |