Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- 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
- runViaFinalGlobal :: (Member (Final IO) r, Functor f) => MVar (f ()) -> (forall x. f (Sem r x) -> IO (f x)) -> (forall x. f x -> Maybe x) -> (forall x n. e n x -> Strategic IO n x) -> Sem (e ': r) a -> MaybeT IO a
- bomb :: a
Documentation
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.