File: Mathlib/Control/Monad/Cont.lean

full_name: MonadCont.Label
code: structure MonadCont.Label (α : Type w) (m : Type u → Type v) (β : Type u) where
  apply : α → m β
goal: Type (max v w)

full_name: MonadCont.Label.apply
code: structure MonadCont.Label (α : Type w) (m : Type u → Type v) (β : Type u) where
  apply : α → m β
goal: α → m β

full_name: MonadCont.goto
code: def MonadCont.goto {α β} {m : Type u → Type v} (f : MonadCont.Label α m β) (x : α) 
goal: m β

full_name: MonadCont.callCC
code: class MonadCont (m : Type u → Type v) where
  callCC : ∀ {α β}, (MonadCont.Label α m β → m α) → m α
goal: (ContT.Label α m β → m α) → m α

full_name: MonadCont
code: class MonadCont (m : Type u → Type v) where
  callCC : ∀ {α β}, (MonadCont.Label α m β → m α) → m α
goal: Type (max (u + 1) v)

full_name: LawfulMonadCont.callCC_bind_right
code: class LawfulMonadCont (m : Type u → Type v) [Monad m] [MonadCont m]
    extends LawfulMonad m : Prop where
  callCC_bind_right {α ω γ} (cmd : m α) (next : Label ω m γ → α → m ω) :
    (callCC fun f => cmd >>= next f) = cmd >>= fun x => callCC fun f => next f x
  callCC_bind_left {α} (β) (x : α) (dead : Label α m β → β → m α) :
    (callCC fun f : Label α m β => goto f x >>= dead f) = pure x
  callCC_dummy {α β} (dummy : m α) : (callCC fun _ : Label α m β => dummy) = dummy
goal: (MonadCont.callCC fun f => cmd >>= next f) = do
  let x ← cmd
  MonadCont.callCC fun f => next f x

full_name: LawfulMonadCont
code: class LawfulMonadCont (m : Type u → Type v) [Monad m] [MonadCont m]
    extends LawfulMonad m : Prop where
  callCC_bind_right {α ω γ} (cmd : m α) (next : Label ω m γ → α → m ω) :
    (callCC fun f => cmd >>= next f) = cmd >>= fun x => callCC fun f => next f x
  callCC_bind_left {α} (β) (x : α) (dead : Label α m β → β → m α) :
    (callCC fun f : Label α m β => goto f x >>= dead f) = pure x
  callCC_dummy {α β} (dummy : m α) : (callCC fun _ : Label α m β => dummy) = dummy
goal: Prop

full_name: LawfulMonadCont.callCC_dummy
code: class LawfulMonadCont (m : Type u → Type v) [Monad m] [MonadCont m]
    extends LawfulMonad m : Prop where
  callCC_bind_right {α ω γ} (cmd : m α) (next : Label ω m γ → α → m ω) :
    (callCC fun f => cmd >>= next f) = cmd >>= fun x => callCC fun f => next f x
  callCC_bind_left {α} (β) (x : α) (dead : Label α m β → β → m α) :
    (callCC fun f : Label α m β => goto f x >>= dead f) = pure x
  callCC_dummy {α β} (dummy : m α) : (callCC fun _ : Label α m β => dummy) = dummy
goal: (MonadCont.callCC fun x => dummy) = dummy

full_name: LawfulMonadCont.callCC_bind_left
code: class LawfulMonadCont (m : Type u → Type v) [Monad m] [MonadCont m]
    extends LawfulMonad m : Prop where
  callCC_bind_right {α ω γ} (cmd : m α) (next : Label ω m γ → α → m ω) :
    (callCC fun f => cmd >>= next f) = cmd >>= fun x => callCC fun f => next f x
  callCC_bind_left {α} (β) (x : α) (dead : Label α m β → β → m α) :
    (callCC fun f : Label α m β => goto f x >>= dead f) = pure x
  callCC_dummy {α β} (dummy : m α) : (callCC fun _ : Label α m β => dummy) = dummy
goal: (MonadCont.callCC fun f => ContT.goto f x >>= dead f) = pure x

full_name: ContT
code: def ContT (r : Type u) (m : Type u → Type v) (α : Type w) 
goal: Type (max v w)

full_name: Cont
code: abbrev Cont (r : Type u) (α : Type w) 
goal: Type (max u w)

full_name: ContT.run
code: def run : ContT r m α → (α → m r) → m r 
goal: ContT r m α → (α → m r) → m r

full_name: ContT.map
code: def map (f : m r → m r) (x : ContT r m α) : ContT r m α 
goal: ContT r m α

full_name: ContT.run_contT_map_contT
code: theorem run_contT_map_contT (f : m r → m r) (x : ContT r m α) : run (map f x) = f ∘ run x 
goal: (ContT.map f x).run = f ∘ x.run

full_name: ContT.withContT
code: def withContT (f : (β → m r) → α → m r) (x : ContT r m α) : ContT r m β 
goal: ContT r m β

full_name: ContT.run_withContT
code: theorem run_withContT (f : (β → m r) → α → m r) (x : ContT r m α) :
    run (withContT f x) = run x ∘ f 
goal: (ContT.withContT f x).run = x.run ∘ f

full_name: ContT.ext
code: @[ext]
protected theorem ext {x y : ContT r m α} (h : ∀ f, x.run f = y.run f) : x = y 
goal: x = y

full_name: ContT.instMonad
code: instance : Monad (ContT r m) 
goal: Monad (ContT r m)

full_name: ContT.instLawfulMonad
code: instance : LawfulMonad (ContT r m) 
goal: LawfulMonad (ContT r m)

full_name: ContT.monadLift
code: def monadLift [Monad m] {α} : m α → ContT r m α 
goal: m α → ContT r m α

full_name: ContT.instMonadLiftOfMonad
code: instance [Monad m] : MonadLift m (ContT r m) 
goal: MonadLift m (ContT r m)

full_name: ContT.monadLift_bind
code: theorem monadLift_bind [Monad m] [LawfulMonad m] {α β} (x : m α) (f : α → m β) :
    (monadLift (x >>= f) : ContT r m β) = monadLift x >>= monadLift ∘ f 
goal: ContT.monadLift (x >>= f) = ContT.monadLift x >>= ContT.monadLift ∘ f

full_name: ContT.instMonadCont
code: instance : MonadCont (ContT r m) 
goal: MonadCont (ContT r m)

full_name: ContT.instLawfulMonadCont
code: instance : LawfulMonadCont (ContT r m) 
goal: LawfulMonadCont (ContT r m)

full_name: ContT.instMonadExcept
code: instance (ε) [MonadExcept ε m] : MonadExcept ε (ContT r m) 
goal: MonadExcept ε (ContT r m)

full_name: ExceptT.mkLabel
code: def ExceptT.mkLabel {α β ε} : Label (Except.{u, u} ε α) m β → Label α (ExceptT ε m) β
  
goal: ContT.Label (Except ε α) m β → ContT.Label α (ExceptT ε m) β

full_name: ExceptT.goto_mkLabel
code: theorem ExceptT.goto_mkLabel {α β ε : Type _} (x : Label (Except.{u, u} ε α) m β) (i : α) :
    goto (ExceptT.mkLabel x) i = ExceptT.mk (Except.ok <$> goto x (Except.ok i)) 
goal: ContT.goto (ExceptT.mkLabel x) i = ExceptT.mk (Except.ok <$> ContT.goto x (Except.ok i))

full_name: ExceptT.callCC
code: nonrec def ExceptT.callCC {ε} [MonadCont m] {α β : Type _}
    (f : Label α (ExceptT ε m) β → ExceptT ε m α) : ExceptT ε m α 
goal: ExceptT ε m α

full_name: instMonadContExceptT
code: instance {ε} [MonadCont m] : MonadCont (ExceptT ε m) 
goal: MonadCont (ExceptT ε m)

full_name: instLawfulMonadContExceptT
code: instance {ε} [MonadCont m] [LawfulMonadCont m] : LawfulMonadCont (ExceptT ε m) 
goal: LawfulMonadCont (ExceptT ε m)

full_name: OptionT.mkLabel
code: def OptionT.mkLabel {α β} : Label (Option.{u} α) m β → Label α (OptionT m) β
  
goal: ContT.Label (Option α) m β → ContT.Label α (OptionT m) β

full_name: OptionT.goto_mkLabel
code: theorem OptionT.goto_mkLabel {α β : Type _} (x : Label (Option.{u} α) m β) (i : α) :
    goto (OptionT.mkLabel x) i = OptionT.mk (goto x (some i) >>= fun a => pure (some a)) 
goal: ContT.goto (OptionT.mkLabel x) i =
  OptionT.mk do
    let a ← ContT.goto x (some i)
    pure (some a)

full_name: OptionT.callCC
code: nonrec def OptionT.callCC [MonadCont m] {α β : Type _} (f : Label α (OptionT m) β → OptionT m α) :
    OptionT m α 
goal: OptionT m α

full_name: instMonadContOptionT
code: instance [MonadCont m] : MonadCont (OptionT m) 
goal: MonadCont (OptionT m)

full_name: instLawfulMonadContOptionT
code: instance [MonadCont m] [LawfulMonadCont m] : LawfulMonadCont (OptionT m) 
goal: LawfulMonadCont (OptionT m)

full_name: WriterT.mkLabel
code: def WriterT.mkLabel {α β ω} [EmptyCollection ω] : Label (α × ω) m β → Label α (WriterT ω m) β
  
goal: ContT.Label (α × ω) m β → ContT.Label α (WriterT ω m) β

full_name: WriterT.mkLabel'
code: def WriterT.mkLabel' {α β ω} [Monoid ω] : Label (α × ω) m β → Label α (WriterT ω m) β
  
goal: ContT.Label (α × ω) m β → ContT.Label α (WriterT ω m) β

full_name: WriterT.goto_mkLabel
code: theorem WriterT.goto_mkLabel {α β ω : Type _} [EmptyCollection ω] (x : Label (α × ω) m β) (i : α) :
    goto (WriterT.mkLabel x) i = monadLift (goto x (i, ∅)) 
goal: ContT.goto (WriterT.mkLabel x) i = monadLift (ContT.goto x (i, ∅))

full_name: WriterT.goto_mkLabel'
code: theorem WriterT.goto_mkLabel' {α β ω : Type _} [Monoid ω] (x : Label (α × ω) m β) (i : α) :
    goto (WriterT.mkLabel' x) i = monadLift (goto x (i, 1)) 
goal: ContT.goto (WriterT.mkLabel' x) i = monadLift (ContT.goto x (i, 1))

full_name: WriterT.callCC
code: nonrec def WriterT.callCC [MonadCont m] {α β ω : Type _} [EmptyCollection ω]
    (f : Label α (WriterT ω m) β → WriterT ω m α) : WriterT ω m α 
goal: WriterT ω m α

full_name: WriterT.callCC'
code: def WriterT.callCC' [MonadCont m] {α β ω : Type _} [Monoid ω]
    (f : Label α (WriterT ω m) β → WriterT ω m α) : WriterT ω m α 
goal: WriterT ω m α

full_name: instMonadContWriterTOfMonadOfEmptyCollection
code: instance (ω) [Monad m] [EmptyCollection ω] [MonadCont m] : MonadCont (WriterT ω m) 
goal: MonadCont (WriterT ω m)

full_name: instMonadContWriterTOfMonadOfMonoid
code: instance (ω) [Monad m] [Monoid ω] [MonadCont m] : MonadCont (WriterT ω m) 
goal: MonadCont (WriterT ω m)

full_name: StateT.mkLabel
code: def StateT.mkLabel {α β σ : Type u} : Label (α × σ) m (β × σ) → Label α (StateT σ m) β
  
goal: ContT.Label (α × σ) m (β × σ) → ContT.Label α (StateT σ m) β

full_name: StateT.goto_mkLabel
code: theorem StateT.goto_mkLabel {α β σ : Type u} (x : Label (α × σ) m (β × σ)) (i : α) :
    goto (StateT.mkLabel x) i = StateT.mk (fun s => goto x (i, s)) 
goal: ContT.goto (StateT.mkLabel x) i = StateT.mk fun s => ContT.goto x (i, s)

full_name: StateT.callCC
code: nonrec def StateT.callCC {σ} [MonadCont m] {α β : Type _}
    (f : Label α (StateT σ m) β → StateT σ m α) : StateT σ m α 
goal: StateT σ m α

full_name: instMonadContStateT
code: instance {σ} [MonadCont m] : MonadCont (StateT σ m) 
goal: MonadCont (StateT σ m)

full_name: instLawfulMonadContStateT
code: instance {σ} [Monad m] [MonadCont m] [LawfulMonadCont m] : LawfulMonadCont (StateT σ m) 
goal: LawfulMonadCont (StateT σ m)

full_name: ReaderT.mkLabel
code: def ReaderT.mkLabel {α β} (ρ) : Label α m β → Label α (ReaderT ρ m) β
  
goal: ContT.Label α m β → ContT.Label α (ReaderT ρ m) β

full_name: ReaderT.goto_mkLabel
code: theorem ReaderT.goto_mkLabel {α ρ β} (x : Label α m β) (i : α) :
    goto (ReaderT.mkLabel ρ x) i = monadLift (goto x i) 
goal: ContT.goto (ReaderT.mkLabel ρ x) i = monadLift (ContT.goto x i)

full_name: ReaderT.callCC
code: nonrec def ReaderT.callCC {ε} [MonadCont m] {α β : Type _}
    (f : Label α (ReaderT ε m) β → ReaderT ε m α) : ReaderT ε m α 
goal: ReaderT ε m α

full_name: instMonadContReaderT
code: instance {ρ} [MonadCont m] : MonadCont (ReaderT ρ m) 
goal: MonadCont (ReaderT ρ m)

full_name: instLawfulMonadContReaderT
code: instance {ρ} [Monad m] [MonadCont m] [LawfulMonadCont m] : LawfulMonadCont (ReaderT ρ m) 
goal: LawfulMonadCont (ReaderT ρ m)

full_name: ContT.equiv
code: /-- reduce the equivalence between two continuation passing monads to the equivalence between
their underlying monad -/
def ContT.equiv {m₁ : Type u₀ → Type v₀} {m₂ : Type u₁ → Type v₁} {α₁ r₁ : Type u₀}
    {α₂ r₂ : Type u₁} (F : m₁ r₁ ≃ m₂ r₂) (G : α₁ ≃ α₂) : ContT r₁ m₁ α₁ ≃ ContT r₂ m₂ α₂ 
goal: ContT r₁ m₁ α₁ ≃ ContT r₂ m₂ α₂