An alternative constructor for LawfulMonad which has more
defaultable fields in the common case.
Equations
- (_ : LawfulMonad (Except ε)) = (_ : LawfulMonad (Except ε))
Equations
- (_ : LawfulApplicative (Except ε)) = (_ : LawfulApplicative (Except ε))
Equations
- (_ : LawfulFunctor (Except ε)) = (_ : LawfulFunctor (Except ε))
Equations
SatisfiesM #
The SatisfiesM predicate works over an arbitrary (lawful) monad / applicative / functor,
and enables Hoare-like reasoning over monadic expressions. For example, given a monadic
function f : α → m β, to say that the return value of f satisfies Q whenever
the input satisfies P, we write ∀ a, P a → SatisfiesM Q (f a).
SatisfiesM p (x : m α) lifts propositions over a monad. It asserts that x may as well
have the type x : m {a // p a}, because there exists some m {a // p a} whose image is x.
So p is the postcondition of the monadic value.
Equations
- SatisfiesM p x = ∃ (x' : m { a : α // p a }), Subtype.val <$> x' = x
Instances For
If p is always true, then every x satisfies it.
If p is always true, then every x satisfies it.
(This is the strongest postcondition version of of_true.)
The SatisfiesM p x predicate is monotonic in p.
SatisfiesM distributes over <$>, general version.
SatisfiesM distributes over <$>, strongest postcondition version.
(Use this for reasoning forward from assumptions.)
SatisfiesM distributes over <$>, weakest precondition version.
(Use this for reasoning backward from the goal.)
SatisfiesM distributes over mapConst, general version.
SatisfiesM distributes over pure, general version / weakest precondition version.
SatisfiesM distributes over <*>, general version.
SatisfiesM distributes over <*>, strongest postcondition version.
SatisfiesM distributes over <*>, weakest precondition version 1.
(Use this when x and the goal are known and f is a subgoal.)
SatisfiesM distributes over <*>, weakest precondition version 2.
(Use this when f and the goal are known and x is a subgoal.)
SatisfiesM distributes over <*, general version.
SatisfiesM distributes over *>, general version.
SatisfiesM distributes over >>=, general version.
SatisfiesM distributes over >>=, weakest precondition version.