Morphisms Between Monads #
structure
MonadHom
(m : Type u → Type v)
[Pure m]
[Bind m]
(n : Type u → Type w)
[Pure n]
[Bind n]
:
Type (max (max (u + 1) v) w)
Structure to represent a well-behaved mapping between computations in two monads m
and n
.
This is similar to MonadLift
but isn't a type-class but rather an actual object.
This is useful for non-canonical mappings that shouldn't be applied automatically in general.
We also enforce similar laws to LawfulMonadLift
.
- toFun {α : Type u} : m α → n α
Instances For
Equations
- «term_→ᵐ_» = Lean.ParserDescr.trailingNode `«term_→ᵐ_» 25 26 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " →ᵐ ") (Lean.ParserDescr.cat `term 25))
Instances For
instance
instCoeFunMonadHomForallForall
(m : Type u → Type v)
[Pure m]
[Bind m]
(n : Type u → Type w)
[Pure n]
[Bind n]
:
View a monad map as a function between computations. Note we can't have a full
FunLike
instance because the type parameter α
isn't constrained by the types.
Equations
- instCoeFunMonadHomForallForall m n = { coe := fun (f : m →ᵐ n) {x : Type ?u.55} (x_1 : m x) => f.toFun x_1 }
@[simp]
theorem
MonadHom.mmap_seq
{m : Type u → Type v}
[Monad m]
{n : Type u → Type w}
[Monad n]
{α β : Type u}
[LawfulMonad m]
[LawfulMonad n]
(F : m →ᵐ n)
(x : m (α → β))
(y : m α)
:
@[simp]
theorem
MonadHom.mmap_seqLeft
{m : Type u → Type v}
[Monad m]
{n : Type u → Type w}
[Monad n]
{α β : Type u}
[LawfulMonad m]
[LawfulMonad n]
(F : m →ᵐ n)
(x : m α)
(y : m β)
:
@[simp]
theorem
MonadHom.mmap_seqRight
{m : Type u → Type v}
[Monad m]
{n : Type u → Type w}
[Monad n]
{α β : Type u}
[LawfulMonad m]
[LawfulMonad n]
(F : m →ᵐ n)
(x : m α)
(y : m β)
:
def
MonadHom.ofLift
(m n : Type u → Type v)
[Monad m]
[Monad n]
[MonadLift m n]
[LawfulMonadLift m n]
:
Construct a MonadHom
from a lawful monad lift.
Equations
- MonadHom.ofLift m n = { toFun := fun {α : Type ?u.44} => liftM, toFun_pure' := ⋯, toFun_bind' := ⋯ }