Documentation

Mathlib.Control.Traversable.Instances

LawfulTraversable instances #

This file provides instances of LawfulTraversable for types from the core library: Option, List and Sum.

theorem Option.id_traverse {α : Type u_1} (x : Option α) :
theorem Option.comp_traverse {F G : Type u → Type u} [Applicative F] [Applicative G] [LawfulApplicative G] {α : Type u_1} {β γ : Type u} (f : βF γ) (g : αG β) (x : Option α) :
Option.traverse (Functor.Comp.mk (fun (x : G β) => f <$> x) g) x = Functor.Comp.mk (Option.traverse f <$> Option.traverse g x)
theorem Option.traverse_eq_map_id {α β : Type u_1} (f : αβ) (x : Option α) :
Option.traverse (pure f) x = pure (f <$> x)
theorem Option.naturality {F G : Type u → Type u} [Applicative F] [Applicative G] [LawfulApplicative G] (η : ApplicativeTransformation F G) [LawfulApplicative F] {α : Type u_1} {β : Type u} (f : αF β) (x : Option α) :
(fun {α : Type u} => η.app α) (Option.traverse f x) = Option.traverse ((fun {α : Type u} => η.app α) f) x
theorem List.id_traverse {α : Type u_1} (xs : List α) :
List.traverse pure xs = xs
theorem List.comp_traverse {F G : Type u → Type u} [Applicative F] [Applicative G] [LawfulApplicative G] {α : Type u_1} {β γ : Type u} (f : βF γ) (g : αG β) (x : List α) :
List.traverse (Functor.Comp.mk (fun (x : G β) => f <$> x) g) x = Functor.Comp.mk (List.traverse f <$> List.traverse g x)
theorem List.traverse_eq_map_id {α β : Type u_1} (f : αβ) (x : List α) :
List.traverse (pure f) x = pure (f <$> x)
theorem List.naturality {F G : Type u → Type u} [Applicative F] [Applicative G] [LawfulApplicative G] [LawfulApplicative F] (η : ApplicativeTransformation F G) {α : Type u_1} {β : Type u} (f : αF β) (x : List α) :
(fun {α : Type u} => η.app α) (List.traverse f x) = List.traverse ((fun {α : Type u} => η.app α) f) x
@[simp]
theorem List.traverse_nil {F : Type u → Type u} [Applicative F] {α' β' : Type u} (f : α'F β') :
traverse f [] = pure []
@[simp]
theorem List.traverse_cons {F : Type u → Type u} [Applicative F] {α' β' : Type u} (f : α'F β') (a : α') (l : List α') :
traverse f (a :: l) = (fun (x1 : β') (x2 : List β') => x1 :: x2) <$> f a <*> traverse f l
@[simp]
theorem List.traverse_append {F : Type u → Type u} [Applicative F] {α' β' : Type u} (f : α'F β') [LawfulApplicative F] (as bs : List α') :
traverse f (as ++ bs) = (fun (x1 x2 : List β') => x1 ++ x2) <$> traverse f as <*> traverse f bs
theorem List.mem_traverse {α' β' : Type u} {f : α'Set β'} (l : List α') (n : List β') :
n traverse f l List.Forall₂ (fun (b : β') (a : α') => b f a) n l
theorem Sum.traverse_map {σ : Type u} {G : Type u → Type u} [Applicative G] {α β γ : Type u} (g : αβ) (f : βG γ) (x : σ α) :
theorem Sum.id_traverse {σ α : Type u_1} (x : σ α) :
Sum.traverse pure x = x
theorem Sum.comp_traverse {σ : Type u} {F G : Type u → Type u} [Applicative F] [Applicative G] [LawfulApplicative G] {α β γ : Type u} (f : βF γ) (g : αG β) (x : σ α) :
Sum.traverse (Functor.Comp.mk (fun (x : G β) => f <$> x) g) x = Functor.Comp.mk (Sum.traverse f <$> Sum.traverse g x)
theorem Sum.traverse_eq_map_id {σ α β : Type u} (f : αβ) (x : σ α) :
Sum.traverse (pure f) x = pure (f <$> x)
theorem Sum.map_traverse {σ : Type u} {G : Type u → Type u} [Applicative G] [LawfulApplicative G] {α : Type u_1} {β γ : Type u} (g : αG β) (f : βγ) (x : σ α) :
(fun (x : σ β) => f <$> x) <$> Sum.traverse g x = Sum.traverse (fun (x : α) => f <$> g x) x
theorem Sum.naturality {σ : Type u} {F G : Type u → Type u} [Applicative F] [Applicative G] [LawfulApplicative G] [LawfulApplicative F] (η : ApplicativeTransformation F G) {α : Type u_1} {β : Type u} (f : αF β) (x : σ α) :
(fun {α : Type u} => η.app α) (Sum.traverse f x) = Sum.traverse ((fun {α : Type u} => η.app α) f) x
Equations
  • =