Monadic operations #
mapM #
Alternate (non-tail-recursive) form of mapM for proofs.
Note that we can not have this as the main definition and replace it using a @[csimp]
lemma,
because they are only equal when m
is a LawfulMonad
.
Equations
- List.mapM' f [] = pure []
- List.mapM' f (a :: l) = do let __do_lift ← f a let __do_lift_1 ← List.mapM' f l pure (__do_lift :: __do_lift_1)
Instances For
Auxiliary lemma for mapM_eq_reverse_foldlM_cons
.
filterMapM #
flatMapM #
foldlM and foldrM #
forM #
forIn' #
We can express a for loop over a list as a fold,
in which whenever we reach .done b
we keep that value through the rest of the fold.
We can express a for loop over a list which always yields as a fold.
We can express a for loop over a list as a fold,
in which whenever we reach .done b
we keep that value through the rest of the fold.
We can express a for loop over a list which always yields as a fold.
allM #
Recognizing higher order functions using a function that only depends on the value. #
This lemma identifies monadic folds over lists of subtypes, where the function only depends on the value, not the proposition, and simplifies these to the function directly taking the value.
This lemma identifies monadic folds over lists of subtypes, where the function only depends on the value, not the proposition, and simplifies these to the function directly taking the value.
This lemma identifies monadic maps over lists of subtypes, where the function only depends on the value, not the proposition, and simplifies these to the function directly taking the value.