Equations
Equations
- reader_t.pure a = ⟨λ (r : ρ), has_pure.pure a⟩
Equations
Equations
- reader_t.lift a = ⟨λ (r : ρ), a⟩
Equations
- reader_t.has_monad_lift m = {monad_lift := reader_t.lift _inst_2}
Equations
- reader_t.monad_functor ρ m m' = {monad_map := reader_t.monad_map _inst_3}
Equations
- reader_t.failure = ⟨λ (s : ρ), failure⟩
Equations
- reader_t.alternative = {to_applicative := {to_functor := {map := λ (_x _x_1 : Type u) (x : _x → _x_1) (y : reader_t ρ m _x), has_pure.pure x <*> y, map_const := λ (α β : Type u), (λ (x : β → α) (y : reader_t ρ m β), has_pure.pure x <*> y) ∘ function.const β}, to_has_pure := applicative.to_has_pure monad.to_applicative, to_has_seq := applicative.to_has_seq monad.to_applicative, to_has_seq_left := {seq_left := λ (α β : Type u) (a : reader_t ρ m α) (b : reader_t ρ m β), (λ (_x _x_1 : Type u) (x : _x → _x_1) (y : reader_t ρ m _x), has_pure.pure x <*> y) α (β → α) (function.const β) a <*> b}, to_has_seq_right := {seq_right := λ (α β : Type u) (a : reader_t ρ m α) (b : reader_t ρ m β), (λ (_x _x_1 : Type u) (x : _x → _x_1) (y : reader_t ρ m _x), has_pure.pure x <*> y) α (β → β) (function.const α id) a <*> b}}, to_has_orelse := {orelse := reader_t.orelse _inst_2}, failure := reader_t.failure _inst_2}
Equations
- reader_t.monad_except ε = {throw := λ (α : Type u), reader_t.lift ∘ monad_except.throw, catch := λ (α : Type u) (x : reader_t ρ m α) (c : ε → reader_t ρ m α), ⟨λ (r : ρ), monad_except.catch (x.run r) (λ (e : ε), (c e).run r)⟩}
- read : m ρ
An implementation of MonadReader.
It does not contain local
because this function cannot be lifted using monad_lift
.
Instead, the monad_reader_adapter
class provides the more general adapt_reader
function.
Note: This class can be seen as a simplification of the more "principled" definition
lean
class monad_reader (ρ : out_param (Type u)) (n : Type u → Type u) :=
(lift {α : Type u} : (∀ {m : Type u → Type u} [monad m], reader_t ρ m α) → n α)
Instances
Equations
Equations
- reader_t.monad_reader = {read := reader_t.read _inst_1}
- adapt_reader : Π {α : Type ?}, (ρ' → ρ) → m α → m' α
Adapt a monad stack, changing the type of its top-most environment.
This class is comparable to Control.Lens.Magnify, but does not use lenses (why would it), and is derived automatically for any transformer implementing monad_functor
.
Note: This class can be seen as a simplification of the more "principled" definition
lean
class monad_reader_functor (ρ ρ' : out_param (Type u)) (n n' : Type u → Type u) :=
(map {α : Type u} : (∀ {m : Type u → Type u} [monad m], reader_t ρ m α → reader_t ρ' m α) → n α → n' α)
Equations
- monad_reader_adapter_trans = {adapt_reader := λ (α : Type u) (f : ρ' → ρ), monad_functor_t.monad_map (λ (α : Type u), monad_reader_adapter.adapt_reader f)}
Equations
- reader_t.monad_reader_adapter = {adapt_reader := λ (α : Type u), reader_t.adapt}
Equations
- reader_t.monad_run ρ m out = {run := λ (α : Type u) (x : reader_t ρ m α), monad_run.run ∘ x.run}