feat(library/init/control/lift): add comment
This commit is contained in:
parent
5d3f421e70
commit
c7762d07c1
1 changed files with 9 additions and 6 deletions
|
|
@ -46,27 +46,30 @@ instance has_monad_lift_t_refl (m) : has_monad_lift_t m m :=
|
|||
/-- A functor in the control of monads. Can be used to lift monad-transforming functions.
|
||||
Based on pipes' [MFunctor](https://hackage.haskell.org/package/pipes-2.4.0/docs/Control-MFunctor.html),
|
||||
but not restricted to monad transformers.
|
||||
Alternatively, an implementation of [MonadTransFunctor](http://duairc.netsoc.ie/layers-docs/Control-Monad-Layer.html#t:MonadTransFunctor). -/
|
||||
Alternatively, an implementation of [MonadTransFunctor](http://duairc.netsoc.ie/layers-docs/Control-Monad-Layer.html#t:MonadTransFunctor).
|
||||
|
||||
|
||||
Remark: other libraries equate `m` and `m'`, and `n` and `n'`. We need to distinguish them to be able to implement
|
||||
gadgets such as `monad_state_adapter` and `monad_reader_adapter`. -/
|
||||
class monad_functor (m m' : Type u → Type v) (n n' : Type u → Type w) :=
|
||||
(monad_map {} {α : Type u} : (∀ {α}, m α → m' α) → n α → n' α)
|
||||
(monad_map {} {α : Type u} : (∀ {β}, m β → m' β) → n α → n' α)
|
||||
|
||||
/-- The reflexive-transitive closure of `monad_functor`.
|
||||
`monad_map` is used to transitively lift monad morphisms such as `state_t.zoom`.
|
||||
A generalization of [MonadLiftFunctor](http://duairc.netsoc.ie/layers-docs/Control-Monad-Layer.html#t:MonadLiftFunctor), which can only lift endomorphisms (i.e. m = m', n = n'). -/
|
||||
class monad_functor_t (m m' : Type u → Type v) (n n' : Type u → Type w) :=
|
||||
(monad_map {} {α : Type u} : (∀ {α}, m α → m' α) → n α → n' α)
|
||||
(monad_map {} {α : Type u} : (∀ {β}, m β → m' β) → n α → n' α)
|
||||
|
||||
export monad_functor_t (monad_map)
|
||||
|
||||
instance monad_functor_t_trans (m m' n n' o o') [monad_functor n n' o o'] [monad_functor_t m m' n n'] :
|
||||
monad_functor_t m m' o o' :=
|
||||
⟨λ α f, monad_functor.monad_map (λ α, (monad_map @f : n α → n' α))⟩
|
||||
⟨λ α f, monad_functor.monad_map (λ β, (monad_map @f : n β → n' β))⟩
|
||||
|
||||
instance monad_functor_t_refl (m m') : monad_functor_t m m' m m' :=
|
||||
⟨λ α f, f⟩
|
||||
|
||||
@[simp] lemma monad_map_refl {m m' : Type u → Type v} (f : ∀ {α}, m α → m' α) {α} : (monad_map @f : m α → m' α) = f := rfl
|
||||
|
||||
@[simp] lemma monad_map_refl {m m' : Type u → Type v} (f : ∀ {β}, m β → m' β) {α} : (monad_map @f : m α → m' α) = f := rfl
|
||||
|
||||
/-- Run a monad stack to completion.
|
||||
`run` should be the composition of the transformers' individual `run` functions.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue