@[protected]
Equations
@[protected]
def
reader_t.pure
{ρ : Type u}
{m : Type u → Type v}
[monad m]
{α : Type u}
(a : α) :
reader_t ρ m α
Equations
- reader_t.pure a = ⟨λ (r : ρ), has_pure.pure a⟩
@[protected, instance]
def
reader_t.has_monad_lift
{ρ : Type u}
(m : Type u → Type u_1)
[monad m] :
has_monad_lift m (reader_t ρ m)
Equations
- reader_t.has_monad_lift m = {monad_lift := reader_t.lift _inst_2}
@[protected, instance]
def
reader_t.monad_functor
(ρ : Type u_1)
(m m' : Type u_1 → Type u_2)
[monad m]
[monad m'] :
monad_functor m m' (reader_t ρ m) (reader_t ρ m')
Equations
- reader_t.monad_functor ρ m m' = {monad_map := reader_t.monad_map _inst_3}
@[protected]
def
reader_t.failure
{ρ : Type u}
{m : Type u → Type v}
[monad m]
[alternative m]
{α : Type u} :
reader_t ρ m α
Equations
- reader_t.failure = ⟨λ (s : ρ), failure⟩
@[protected, instance]
def
reader_t.alternative
{ρ : Type u}
{m : Type u → Type v}
[monad m]
[alternative m] :
alternative (reader_t ρ m)
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}
@[protected, instance]
def
reader_t.monad_except
{ρ : Type u}
{m : Type u → Type v}
[monad m]
(ε : out_param (Type u_1))
[monad m]
[monad_except ε m] :
monad_except ε (reader_t ρ m)
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)⟩}
@[class]
- 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
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 of this typeclass
Instances of other typeclasses for monad_reader
- monad_reader.has_sizeof_inst
@[protected, instance]
def
monad_reader_trans
{ρ : Type u}
{m : Type u → Type v}
{n : Type u → Type w}
[monad_reader ρ m]
[has_monad_lift m n] :
monad_reader ρ n
Equations
@[protected, instance]
def
reader_t.monad_reader
{ρ : Type u}
{m : Type u → Type v}
[monad m] :
monad_reader ρ (reader_t ρ m)
Equations
- reader_t.monad_reader = {read := reader_t.read _inst_1}
@[class]
structure
monad_reader_adapter
(ρ ρ' : out_param (Type u))
(m m' : Type u → Type v) :
Type (max (u+1) v)
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
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' α)
Instances of this typeclass
Instances of other typeclasses for monad_reader_adapter
- monad_reader_adapter.has_sizeof_inst
@[protected, instance]
def
monad_reader_adapter_trans
{ρ ρ' : Type u}
{m m' n n' : Type u → Type v}
[monad_reader_adapter ρ ρ' m m']
[monad_functor m m' n n'] :
monad_reader_adapter ρ ρ' 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)}
@[protected, instance]
def
reader_t.monad_reader_adapter
{ρ ρ' : Type u}
{m : Type u → Type v}
[monad m] :
monad_reader_adapter ρ ρ' (reader_t ρ m) (reader_t ρ' m)
Equations
- reader_t.monad_reader_adapter = {adapt_reader := λ (α : Type u), reader_t.adapt}