Monadic filtering with pure tests and under monad morphisms #
Core List.filterM p xs runs the effectful test p once on each element of xs, from left to
right, and keeps the accepted elements in order. Core proves little about it. This module records
the two facts that let a program written with List.filterM be run purely and transported along
monad morphisms. Core defines List.filterM through the accumulator List.filterAuxM without
exposing the body, so this module imports Init.Data.List.Control with import all, as core's
own Init.Data.List.Monadic does.
Main results #
List.filterM_pure: with pure tests,List.filterMisList.filter.Cslib.IsMonadHom.map_filterM: monad morphisms commute withList.filterM.
@[simp]
theorem List.filterM_pure {α : Type} {m : Type → Type u_1} [Monad m] [LawfulMonad m] (p : α → Bool) (xs : List α) :
With pure tests, core List.filterM is List.filter.
theorem Cslib.IsMonadHom.map_filterM {α : Type} {m : Type → Type u_1} {n : Type → Type u_2} [Monad m] [Monad n] {f : {γ : Type} → m γ → n γ} (hf : IsMonadHom m n fun {α : Type} => f) (p : α → m Bool) (xs : List α) :
Monad morphisms commute with core List.filterM.