- apply : α → m β
def
monad_cont.goto
{α : Type u_1}
{β : Type u}
{m : Type u → Type v} :
monad_cont.label α m β → α → m β
Equations
- monad_cont.goto f x = f.apply x
@[class]
- call_cc : Π {α β : Type ?}, (monad_cont.label α m β → m α) → m α
@[class]
- to_is_lawful_monad : is_lawful_monad m
- call_cc_bind_right : ∀ {α ω γ : Type ?} (cmd : m α) (next : monad_cont.label ω m γ → α → m ω), monad_cont.call_cc (λ (f : monad_cont.label ω m γ), cmd >>= next f) = cmd >>= λ (x : α), monad_cont.call_cc (λ (f : monad_cont.label ω m γ), next f x)
- call_cc_bind_left : ∀ {α : Type ?} (β : Type ?) (x : α) (dead : monad_cont.label α m β → β → m α), monad_cont.call_cc (λ (f : monad_cont.label α m β), monad_cont.goto f x >>= dead f) = has_pure.pure x
- call_cc_dummy : ∀ {α β : Type ?} (dummy : m α), monad_cont.call_cc (λ (f : monad_cont.label α m β), dummy) = dummy
Equations
Equations
- cont_t.map f x = f ∘ x
theorem
cont_t.run_cont_t_map_cont_t
{r : Type u}
{m : Type u → Type v}
{α : Type w}
(f : m r → m r)
(x : cont_t r m α) :
(cont_t.map f x).run = f ∘ x.run
Equations
- cont_t.with_cont_t f x = λ (g : β → m r), x (f g)
theorem
cont_t.run_with_cont_t
{r : Type u}
{m : Type u → Type v}
{α β : Type w}
(f : (β → m r) → α → m r)
(x : cont_t r m α) :
(cont_t.with_cont_t f x).run = x.run ∘ f
@[instance]
Equations
@[instance]
Equations
def
cont_t.monad_lift
{r : Type u}
{m : Type u → Type v}
[monad m]
{α : Type u} :
m α → cont_t r m α
Equations
- cont_t.monad_lift = λ (x : m α) (f : α → m r), x >>= f
@[instance]
def
cont_t.has_monad_lift
{r : Type u}
{m : Type u → Type v}
[monad m] :
has_monad_lift m (cont_t r m)
Equations
- cont_t.has_monad_lift = {monad_lift := λ (α : Type u), cont_t.monad_lift}
theorem
cont_t.monad_lift_bind
{r : Type u}
{m : Type u → Type v}
[monad m]
[is_lawful_monad m]
{α β : Type u}
(x : m α)
(f : α → m β) :
cont_t.monad_lift (x >>= f) = cont_t.monad_lift x >>= cont_t.monad_lift ∘ f
@[instance]
Equations
- cont_t.monad_cont = {call_cc := λ (α β : Type u_1) (f : monad_cont.label α (cont_t r m) β → cont_t r m α) (g : α → m r), f {apply := λ (x : α) (h : β → m r), g x} g}
@[instance]
def
cont_t.is_lawful_monad_cont
{r : Type u}
{m : Type u → Type v} :
is_lawful_monad_cont (cont_t r m)
Equations
- cont_t.is_lawful_monad_cont = {to_is_lawful_monad := _, call_cc_bind_right := _, call_cc_bind_left := _, call_cc_dummy := _}
@[instance]
def
cont_t.monad_except
{r : Type u}
{m : Type u → Type v}
(ε : out_param (Type u_1))
[monad_except ε m] :
monad_except ε (cont_t r m)
Equations
- cont_t.monad_except ε = {throw := λ (x : Type u_2) (e : ε) (f : x → m r), monad_except.throw e, catch := λ (α : Type u_2) (act : cont_t r m α) (h : ε → cont_t r m α) (f : α → m r), monad_except.catch (act f) (λ (e : ε), h e f)}
def
except_t.mk_label
{m : Type u → Type v}
[monad m]
{α β ε : Type u} :
monad_cont.label (except ε α) m β → monad_cont.label α (except_t ε m) β
Equations
- except_t.mk_label {apply := f} = {apply := λ (a : α), has_monad_lift_t.monad_lift (f (except.ok a))}
theorem
except_t.goto_mk_label
{m : Type u → Type v}
[monad m]
{α β ε : Type u}
(x : monad_cont.label (except ε α) m β)
(i : α) :
monad_cont.goto (except_t.mk_label x) i = ⟨except.ok <$> monad_cont.goto x (except.ok i)⟩
def
except_t.call_cc
{m : Type u → Type v}
[monad m]
{ε : Type u}
[monad_cont m]
{α β : Type u} :
(monad_cont.label α (except_t ε m) β → except_t ε m α) → except_t ε m α
Equations
- except_t.call_cc f = ⟨monad_cont.call_cc (λ (x : monad_cont.label (except ε α) m β), (f (except_t.mk_label x)).run)⟩
@[instance]
def
except_t.monad_cont
{m : Type u → Type v}
[monad m]
{ε : Type u}
[monad_cont m] :
monad_cont (except_t ε m)
Equations
- except_t.monad_cont = {call_cc := λ (α β : Type u), except_t.call_cc}
@[instance]
def
except_t.is_lawful_monad_cont
{m : Type u → Type v}
[monad m]
{ε : Type u}
[monad_cont m]
[is_lawful_monad_cont m] :
is_lawful_monad_cont (except_t ε m)
Equations
- except_t.is_lawful_monad_cont = {to_is_lawful_monad := _, call_cc_bind_right := _, call_cc_bind_left := _, call_cc_dummy := _}
def
option_t.mk_label
{m : Type u → Type v}
[monad m]
{α β : Type u} :
monad_cont.label (option α) m β → monad_cont.label α (option_t m) β
Equations
- option_t.mk_label {apply := f} = {apply := λ (a : α), has_monad_lift_t.monad_lift (f (option.some a))}
theorem
option_t.goto_mk_label
{m : Type u → Type v}
[monad m]
{α β : Type u}
(x : monad_cont.label (option α) m β)
(i : α) :
monad_cont.goto (option_t.mk_label x) i = {run := option.some <$> monad_cont.goto x (option.some i)}
def
option_t.call_cc
{m : Type u → Type v}
[monad m]
[monad_cont m]
{α β : Type u} :
(monad_cont.label α (option_t m) β → option_t m α) → option_t m α
Equations
- option_t.call_cc f = {run := monad_cont.call_cc (λ (x : monad_cont.label (option α) m β), (f (option_t.mk_label x)).run)}
@[instance]
Equations
- option_t.monad_cont = {call_cc := λ (α β : Type u), option_t.call_cc}
@[instance]
def
option_t.is_lawful_monad_cont
{m : Type u → Type v}
[monad m]
[monad_cont m]
[is_lawful_monad_cont m] :
Equations
- option_t.is_lawful_monad_cont = {to_is_lawful_monad := _, call_cc_bind_right := _, call_cc_bind_left := _, call_cc_dummy := _}
def
writer_t.mk_label
{m : Type u → Type v}
[monad m]
{α : Type u_1}
{β ω : Type u}
[has_one ω] :
monad_cont.label (α × ω) m β → monad_cont.label α (writer_t ω m) β
Equations
- writer_t.mk_label {apply := f} = {apply := λ (a : α), has_monad_lift_t.monad_lift (f (a, 1))}
theorem
writer_t.goto_mk_label
{m : Type u → Type v}
[monad m]
{α : Type u_1}
{β ω : Type u}
[has_one ω]
(x : monad_cont.label (α × ω) m β)
(i : α) :
monad_cont.goto (writer_t.mk_label x) i = has_monad_lift_t.monad_lift (monad_cont.goto x (i, 1))
def
writer_t.call_cc
{m : Type u → Type v}
[monad m]
[monad_cont m]
{α β ω : Type u}
[has_one ω] :
(monad_cont.label α (writer_t ω m) β → writer_t ω m α) → writer_t ω m α
Equations
@[instance]
def
writer_t.monad_cont
{m : Type u → Type v}
[monad m]
(ω : Type u)
[monad m]
[has_one ω]
[monad_cont m] :
monad_cont (writer_t ω m)
Equations
- writer_t.monad_cont ω = {call_cc := λ (α β : Type u), writer_t.call_cc}
def
state_t.mk_label
{m : Type u → Type v}
[monad m]
{α β σ : Type u} :
monad_cont.label (α × σ) m (β × σ) → monad_cont.label α (state_t σ m) β
theorem
state_t.goto_mk_label
{m : Type u → Type v}
[monad m]
{α β σ : Type u}
(x : monad_cont.label (α × σ) m (β × σ))
(i : α) :
monad_cont.goto (state_t.mk_label x) i = ⟨λ (s : σ), monad_cont.goto x (i, s)⟩
def
state_t.call_cc
{m : Type u → Type v}
[monad m]
{σ : Type u}
[monad_cont m]
{α β : Type u} :
(monad_cont.label α (state_t σ m) β → state_t σ m α) → state_t σ m α
Equations
- state_t.call_cc f = ⟨λ (r : σ), monad_cont.call_cc (λ (f' : monad_cont.label (α × σ) m (β × σ)), (f (state_t.mk_label f')).run r)⟩
@[instance]
def
state_t.monad_cont
{m : Type u → Type v}
[monad m]
{σ : Type u}
[monad_cont m] :
monad_cont (state_t σ m)
Equations
- state_t.monad_cont = {call_cc := λ (α β : Type u), state_t.call_cc}
@[instance]
def
state_t.is_lawful_monad_cont
{m : Type u → Type v}
[monad m]
{σ : Type u}
[monad_cont m]
[is_lawful_monad_cont m] :
is_lawful_monad_cont (state_t σ m)
Equations
- state_t.is_lawful_monad_cont = {to_is_lawful_monad := _, call_cc_bind_right := _, call_cc_bind_left := _, call_cc_dummy := _}
def
reader_t.mk_label
{m : Type u → Type v}
[monad m]
{α : Type u_1}
{β : Type u}
(ρ : Type u) :
monad_cont.label α m β → monad_cont.label α (reader_t ρ m) β
Equations
- reader_t.mk_label ρ {apply := f} = {apply := has_monad_lift_t.monad_lift ∘ f}
theorem
reader_t.goto_mk_label
{m : Type u → Type v}
[monad m]
{α : Type u_1}
{ρ β : Type u}
(x : monad_cont.label α m β)
(i : α) :
def
reader_t.call_cc
{m : Type u → Type v}
[monad m]
{ε : Type u}
[monad_cont m]
{α β : Type u} :
(monad_cont.label α (reader_t ε m) β → reader_t ε m α) → reader_t ε m α
Equations
- reader_t.call_cc f = ⟨λ (r : ε), monad_cont.call_cc (λ (f' : monad_cont.label α m β), (f (reader_t.mk_label ε f')).run r)⟩
@[instance]
def
reader_t.monad_cont
{m : Type u → Type v}
[monad m]
{ρ : Type u}
[monad_cont m] :
monad_cont (reader_t ρ m)
Equations
- reader_t.monad_cont = {call_cc := λ (α β : Type u), reader_t.call_cc}
@[instance]
def
reader_t.is_lawful_monad_cont
{m : Type u → Type v}
[monad m]
{ρ : Type u}
[monad_cont m]
[is_lawful_monad_cont m] :
is_lawful_monad_cont (reader_t ρ m)
Equations
- reader_t.is_lawful_monad_cont = {to_is_lawful_monad := _, call_cc_bind_right := _, call_cc_bind_left := _, call_cc_dummy := _}
def
cont_t.equiv
{m₁ : Type u₀ → Type v₀}
{m₂ : Type u₁ → Type v₁}
{α₁ r₁ : Type u₀}
{α₂ r₂ : Type u₁} :
reduce the equivalence between two continuation passing monads to the equivalence between their underlying monad