Modulepolysemy-1.9.2.0Haskell2010
Polysemy.Fixpoint
- 1 type
- 1 value
- Packagepolysemy-1.9.2.0
- Exports2
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceFixpoint.hs
Effect
1 declarationInterpretations
1 declarationRun a Fixpoint effect in terms of a final MonadFix instance.
If you need to run a Fixpoint effect purely, use this together with
Final Identity.
Note: This is subject to the same traps as MonadFix instances for monads with failure: this will throw an exception if you try to recursively use the result of a failed computation in an action whose effect may be observed even though the computation failed.
For example, the following program will throw an exception upon evaluating the final state:
bad :: (Int, Either () Int)
bad =
runIdentity
. runFinal
. fixpointToFinal @Identity
. runLazyState @Int 1
. runError
$ mdo
put a
a <- throw ()
return a
fixpointToFinal also 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
Either e a. The inspector for this effectful state only fails if the
effectful state is a Left value, which therefore doesn't contain any
values of a.
This assumption holds true for all interpreters featured in this package, and is presumably always true for any properly implemented interpreter. fixpointToFinal may throw an exception if it is used together with an interpreter that uses weave improperly.
If fixpointToFinal throws an exception for you, and it can't be due to any of the above, then open an issue over at the GitHub repository for polysemy.