List operations and monad morphisms #
This file proves that monadic operations on lists commute with monad homomorphisms
(and applicative homomorphisms), and that List.reverse is a monad homomorphism on List.
Preservation of list operations under applicative homomorphisms #
theorem
Cslib.IsApplicativeHom.map_listMapA
{m : Type u → Type um}
{n : Type u → Type un}
[Applicative m]
[Applicative n]
{F : {α : Type u} → m α → n α}
(hf : IsApplicativeHom m n fun {α : Type u} => F)
{α : Type v}
{β : Type u}
(f : α → m β)
(l : List α)
:
theorem
Cslib.IsApplicativeHom.map_listForA
{m : Type u → Type um}
{n : Type u → Type un}
[Applicative m]
[Applicative n]
{F : {α : Type u} → m α → n α}
(hf : IsApplicativeHom m n fun {α : Type u} => F)
{α : Type v}
(l : List α)
(f : α → m PUnit.{u + 1})
:
Preservation of list operations under monad homomorphisms #
Preservation of list operations under alternative homomorphisms #
theorem
Cslib.IsAlternativeHom.map_listFirstM
{m : Type u → Type um}
{n : Type u → Type un}
[Alternative m]
[Alternative n]
{F : {α : Type u} → m α → n α}
(hf : IsAlternativeHom m n fun {α : Type u} => F)
{α : Type v}
{β : Type u}
(f : α → m β)
(l : List α)
:
The only monad morphisms on lists are the identity and reversal.