Evaluation Semantics for ExceptT (ErrorT) #
This file provides evaluation semantics for ExceptT ε m computations, lifting
HasEvalPMF m to HasEvalSPMF (ExceptT ε m).
ExceptT ε m α represents computations that can fail with an error of type ε
or succeed with a value of type α. The underlying type is m (Except ε α).
Main definitions #
ExceptT.toSPMF: Monad homomorphismExceptT ε m →ᵐ SPMFwhenmhasHasEvalPMF- Instance
HasEvalSPMF (ExceptT ε m)when[HasEvalPMF m]
Design notes #
Similar to OptionT, we lift HasEvalPMF m to HasEvalSPMF (ExceptT ε m) because
error cases contribute failure mass. We map:
Except.ok x→ probability mass atsome xExcept.error e→ failure mass (mapped tonone)
This means we only support one layer of failure. If you need nested error handling,
you'll need to work with the underlying m (Except ε α) type directly.
NOTE: this should be a high priority to add for more complex proofs
Standalone HasEvalSet (ExceptT ε m) instance under the weaker [HasEvalSet m] assumption.
This is deliberately kept separate from the HasEvalSPMF (ExceptT ε m) instance below, which
re-exports the same toSet to make the resulting typeclass diamond definitionally equal.
Keeping this standalone instance means support on ExceptT ε m works without requiring a
full HasEvalSPMF m — only HasEvalSet m is needed (e.g., for support_liftM).
Monad homomorphism from ExceptT ε m to SPMF, treating errors as failure mass.
Given mx : ExceptT ε m α, we evaluate the underlying m (Except ε α) to an SPMF,
then route Except.ok x to pure x and Except.error _ to failure.
Instances For
Lift HasEvalPMF m to HasEvalSPMF (ExceptT ε m).
Errors contribute to failure mass.