Predicate transformers #
PredTrans Pred EPosts α wraps a map from a normal postcondition α → Pred and an exception
postcondition EPosts to a precondition Pred. The order and the chain-complete suprema are the
pointwise ones of the function space.
PredTrans Pred EPosts is a monad, so monadic programs can be interpreted by a monad morphism into
it. This module provides that monad structure, the apply computation rules of the monadic
combinators, the push family that moves a result type into a postcondition, and the standard
monad class instances.
A predicate transformer from postconditions to preconditions.
Given a return type α, a lattice Pred for assertions, and an exception assertion type EPosts,
PredTrans Pred EPosts α wraps a function (α → Pred) → EPosts → Pred.
- apply : (α → Pred) → EPosts → Pred
Apply the predicate transformer to a postcondition and exception postcondition.
Instances For
Partial order on predicate transformers, inherited from the function space.
Monotonicity property for a predicate transformer: if both post and eposts grow,
then the resulting precondition grows.
Instances For
Conjunctivity property for a predicate transformer: the meet of two preconditions lies below the precondition of the componentwise meet of the postconditions.
Instances For
Monad Structure #
apply_* computation rules #
Equations that reduce (expr).apply post eposts for each monadic combinator.
Unfolding PredTrans.pure through apply.
Unfolding PredTrans.bind through apply.
Arguments #
Combinators that add or remove a state argument.
Adds a state argument to a predicate transformer.
Given a state-dependent transformer σ → PredTrans Pred EPosts (α × σ), produces a transformer
over σ → Pred that threads the state through postconditions.
Instances For
Results #
Postconditions for Except and Option results, and the transformer combinators built on them.
A normal result uses the normal postcondition.
An exceptional result uses the exception postcondition.
A present result uses the normal postcondition.
An absent result uses the absent postcondition.
Adds an exception postcondition layer to a predicate transformer, mirroring ExceptT.
Given a transformer over Except ε α, produces one over α with an additional exception
postcondition for ε. The normal and error postconditions are combined via pushExcept.
Instances For
Unfolding lemma for pushExceptT.
Adds an early-termination layer to a predicate transformer, mirroring OptionT.
Given a transformer over Option α, produces one over α with an additional exception
postcondition for the none case.
Instances For
Unfolding lemma for pushOptionT.
Exception Instances #
throw and tryCatch on the first exception postcondition, and the combinators that lift the
MonadExceptOf instance through further layers.
tryCatch x handle replaces the first exception postcondition of x with the precondition
of the handler.
Instances For
Unfolding tryCatch through apply: the handler replaces the first exception
postcondition.
Unfolding liftExcept through apply.
Unfolding read through apply.