Documentation

Mathlib.Init.Control.Lawful

Functor Laws, applicative laws, and monad Laws #

def StateT.mk {σ : Type u} {m : Type u → Type v} {α : Type u} (f : σm (α × σ)) :
StateT σ m α
Equations
Instances For
    @[simp]
    theorem StateT.run_mk {σ : Type u} {m : Type u → Type v} {α : Type u} (f : σm (α × σ)) (st : σ) :
    StateT.run (StateT.mk f) st = f st
    @[simp]
    theorem ExceptT.run_mk {α : Type u} {ε : Type u} {m : Type u → Type v} (x : m (Except ε α)) :
    @[simp]
    theorem ExceptT.run_monadLift {α : Type u} {ε : Type u} {m : Type u → Type v} [Monad m] {n : Type u → Type u_1} [MonadLiftT n m] (x : n α) :
    @[simp]
    theorem ExceptT.run_monadMap {α : Type u} {ε : Type u} {m : Type u → Type v} (x : ExceptT ε m α) {n : Type u → Type u_1} [MonadFunctorT n m] (f : {α : Type u} → n αn α) :
    def ReaderT.mk {m : Type u → Type v} {α : Type u} {σ : Type u} (f : σm α) :
    ReaderT σ m α
    Equations
    Instances For
      @[simp]
      theorem ReaderT.run_mk {m : Type u → Type v} {α : Type u} {σ : Type u} (f : σm α) (r : σ) :
      theorem OptionT.ext {α : Type u} {m : Type u → Type v} {x : OptionT m α} {x' : OptionT m α} (h : OptionT.run x = OptionT.run x') :
      x = x'
      @[simp]
      theorem OptionT.run_mk {α : Type u} {m : Type u → Type v} (x : m (Option α)) :
      @[simp]
      theorem OptionT.run_pure {α : Type u} {m : Type u → Type v} [Monad m] (a : α) :
      @[simp]
      theorem OptionT.run_bind {α : Type u} {β : Type u} {m : Type u → Type v} (x : OptionT m α) [Monad m] (f : αOptionT m β) :
      OptionT.run (x >>= f) = do let x ← OptionT.run x match x with | some a => OptionT.run (f a) | none => pure none
      @[simp]
      theorem OptionT.run_map {α : Type u} {β : Type u} {m : Type u → Type v} (x : OptionT m α) [Monad m] (f : αβ) [LawfulMonad m] :
      @[simp]
      theorem OptionT.run_monadLift {α : Type u} {m : Type u → Type v} [Monad m] {n : Type u → Type u_1} [MonadLiftT n m] (x : n α) :
      OptionT.run (monadLift x) = do let a ← monadLift x pure (some a)
      @[simp]
      theorem OptionT.run_monadMap {α : Type u} {m : Type u → Type v} (x : OptionT m α) {n : Type u → Type u_1} [MonadFunctorT n m] (f : {α : Type u} → n αn α) :
      Equations
      • =

      Lawfulness of IO #

      At some point core intends to make IO opaque, which would break these proofs As discussed in https://github.com/leanprover/std4/pull/416, it should be possible for core to expose the lawfulness of IO as part of the opaque interface, which would remove the need for these proofs anyway.

      These are not in Std because Std does not want to deal with the churn from such a core refactor.

      Equations
      • =
      instance instLawfulMonadESTInstMonadEST {ε : Type} {σ : Type} :
      Equations
      • =
      Equations
      • =