Safe Haskell | None |
---|---|
Language | Haskell2010 |
Combinators for Interpreting to the Final Monad
interpretFinalGlobal :: forall e a r. Member (Final IO) r => (forall x n. e n x -> Strategic IO n x) -> Sem (e ': r) a -> Sem r a Source #
Like interpretFinal
specialized to IO
, but also tries very hard
to preserve state semantics dependant on the order interpreters are run,
adressing the primary issue with Final
.
Semantically, interpreters written using this behave very much as
though they were written using withLowerToIO
.
However, this does not need to spawn an interpreter thread, making
it more efficient (but not any more safe.)
interpretFinalGlobal
operates under the assumption that any effectful
state which can't be inspected using Inspector
can't contain any
values. For example, the effectful state for runError
is
. The inspector for this effectful state only fails if the
effectful state is a Either
e a
value, which therefore doesn't contain any
values of Left
a
.
The assumption holds true for all interpreters featured in polysemy,
and is presumably always true for any properly implemented interpreter.
interpretFinalGlobal
may throw an exception if it is used together with an
interpreter that uses weave
improperly.
Interpretations for other effects
asyncToIOFinalGlobal :: Member (Final IO) r => Sem (Async ': r) a -> Sem r a Source #
asyncToIOFinal
implemented using interpretFinalGlobal
.
This behaves semantically very much like asyncToIO
,
but doesn't need to spin up an interpreter thread, making it more
efficient (but not any more safe).
resourceToIOFinalGlobal :: Member (Final IO) r => Sem (Resource ': r) a -> Sem r a Source #
resourceToIOFinal
implemented using interpretFinalGlobal
.
This behaves semantically very much like resourceToIO
,
but doesn't need to spin up an interpreter thread,
making it more efficient (but not any more safe).