Evaluation Semantics for ExceptT (ErrorT) #
This file provides evaluation semantics for ExceptT ε m computations, lifting
MonadLiftT m PMF to MonadLiftT (ExceptT ε m) SPMF.
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 →ᵐ SPMFwhenmlifts intoPMF- Instance
MonadLiftT (ExceptT ε m) SPMFwhen[MonadLiftT m PMF] [LawfulMonadLiftT m PMF]
Design notes #
Similar to OptionT, we lift MonadLiftT m PMF to MonadLiftT (ExceptT ε m) SPMF 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.
Standalone MonadLiftT (ExceptT ε m) SetM instance under the weaker [MonadLiftT m SetM]
assumption. Keeping this standalone means support on ExceptT ε m works without requiring a
full MonadLiftT m SPMF lift — only MonadLiftT m SetM is needed.
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 MonadLiftT m PMF to MonadLiftT (ExceptT ε m) SPMF.
Errors contribute to failure mass.
The successful-output support of ExceptT ε m agrees with the output support of its
SPMF semantics, provided the underlying monad has the corresponding bridge. Errors only
contribute failure mass, not successful outputs.