Documentation

CslibFrontier.Foundations.Control.Monad.MapM

Mapping over the result of a monadic list traversal #

Core List.mapM_map moves a function applied to the input list of List.mapM into the traversed program. This module provides the companion for the output list, List.map_mapM: mapping a function over the list that l.mapM f returns is traversing with f and applying that function to each result. It is a general list lemma destined for Lean core.

theorem List.map_mapM {m : Type u → Type v} [Monad m] [LawfulMonad m] {α : Type w} {β γ : Type u} (f : α → m β) (g : β → γ) (l : List α) :
map g <$> mapM f l = mapM (fun (a : α) => g <$> f a) l

Mapping g over the results of a traversal is traversing with g applied to each result.