@[simp]
theorem
Option.forM_map
{m : Type u_1 → Type u_2}
{α : Type u_3}
{β : Type u_4}
[Monad m]
[LawfulMonad m]
(o : Option α)
(g : α → β)
(f : β → m PUnit)
:
(Option.map g o).forM f = o.forM fun (a : α) => f (g a)
theorem
Option.forIn'_congr
{m : Type u_1 → Type u_2}
{α : Type u_3}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
{as bs : Option α}
(w : as = bs)
{b b' : β}
(hb : b = b')
{f : (a' : α) → a' ∈ as → β → m (ForInStep β)}
{g : (a' : α) → a' ∈ bs → β → m (ForInStep β)}
(h : ∀ (a : α) (m_1 : a ∈ bs) (b : β), f a ⋯ b = g a m_1 b)
:
@[simp]
theorem
Option.forIn'_yield_eq_pelim
{m : Type u_1 → Type u_2}
{α : Type u_3}
{β γ : Type u_1}
[Monad m]
[LawfulMonad m]
(o : Option α)
(f : (a : α) → a ∈ o → β → m γ)
(g : (a : α) → a ∈ o → β → γ → β)
(b : β)
:
theorem
Option.forIn'_pure_yield_eq_pelim
{m : Type u_1 → Type u_2}
{α : Type u_3}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
(o : Option α)
(f : (a : α) → a ∈ o → β → β)
(b : β)
:
@[simp]
theorem
Option.forIn'_map
{m : Type u_1 → Type u_2}
{α : Type u_3}
{β : Type u_4}
{γ : Type u_1}
{init : γ}
[Monad m]
[LawfulMonad m]
(o : Option α)
(g : α → β)
(f : (b : β) → b ∈ Option.map g o → γ → m (ForInStep γ))
:
forIn' (Option.map g o) init f = forIn' o init fun (a : α) (h : a ∈ o) (y : γ) => f (g a) ⋯ y
theorem
Option.forIn_eq_elim
{m : Type u_1 → Type u_2}
{α : Type u_3}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
(o : Option α)
(f : α → β → m (ForInStep β))
(b : β)
:
forIn o b f = o.elim (pure b) fun (a : α) => ForInStep.value <$> f a b
@[simp]
theorem
Option.forIn_yield_eq_elim
{m : Type u_1 → Type u_2}
{α : Type u_3}
{β γ : Type u_1}
[Monad m]
[LawfulMonad m]
(o : Option α)
(f : α → β → m γ)
(g : α → β → γ → β)
(b : β)
:
theorem
Option.forIn_pure_yield_eq_elim
{m : Type u_1 → Type u_2}
{α : Type u_3}
{β : Type u_1}
[Monad m]
[LawfulMonad m]
(o : Option α)
(f : α → β → β)
(b : β)
:
(forIn o b fun (a : α) (b : β) => pure (ForInStep.yield (f a b))) = pure (o.elim b fun (a : α) => f a b)
@[simp]
theorem
Option.forIn_id_yield_eq_elim
{α : Type u_1}
{β : Type u_2}
(o : Option α)
(f : α → β → β)
(b : β)
:
(forIn o b fun (a : α) (b : β) => ForInStep.yield (f a b)) = o.elim b fun (a : α) => f a b
@[simp]
theorem
Option.forIn_map
{m : Type u_1 → Type u_2}
{α : Type u_3}
{β : Type u_4}
{γ : Type u_1}
{init : γ}
[Monad m]
[LawfulMonad m]
(o : Option α)
(g : α → β)
(f : β → γ → m (ForInStep γ))
:
forIn (Option.map g o) init f = forIn o init fun (a : α) (y : γ) => f (g a) y