Equations
- instReprEffectKind = { reprPrec := reprEffectKind✝ }
Equations
- instDecidableEqEffectKind x y = if h : x.toCtorIdx = y.toCtorIdx then isTrue ⋯ else isFalse ⋯
NOTE: The Monad
instance below also implies Functor
, Applicative
, etc.
If m
is a Functor
, but not a full Monad
, then e.toMonad m
should still be a functor too.
However, actually having these instances causes diamond problems with the aforementioned instances
implied by Monad
. Thus, we just assume m
is always a monad.
instance
EffectKind.instMonadToMonad
{e : EffectKind}
{m : Type → Type}
[Monad m]
:
Monad (e.toMonad m)
Equations
- One or more equations did not get rendered due to their size.
instance
EffectKind.instLawfulMonadToMonad
{e : EffectKind}
{m : Type → Type}
[Monad m]
[LawfulMonad m]
:
LawfulMonad (e.toMonad m)
Equations
- ⋯ = ⋯
def
EffectKind.return
{m : Type → Type}
{α : Type}
[Monad m]
(e : EffectKind)
(a : α)
:
e.toMonad m α
Instances For
@[simp]
Equations
- ⋯ = ⋯
Instances For
PartialOrder
#
Establish a partial order on EffectKind
- pure_le: ∀ (e : EffectKind), EffectKind.pure.le e
- le_impure: ∀ (e : EffectKind), e.le EffectKind.impure
Instances For
Equations
Instances For
@[simp]
@[simp]
theorem
EffectKind.le_trans
{e1 : EffectKind}
{e2 : EffectKind}
{e3 : EffectKind}
(h12 : e1 ≤ e2)
(h23 : e2 ≤ e3)
:
e1 ≤ e3
@[simp]
theorem
EffectKind.le_antisymm
{e1 : EffectKind}
{e2 : EffectKind}
(h12 : e1 ≤ e2)
(h21 : e2 ≤ e1)
:
e1 = e2
Lattice
#
EffectKind
forms a lattice
Equations
- EffectKind.pure.sup EffectKind.pure = EffectKind.pure
- x✝.sup x = EffectKind.impure
Instances For
Equations
- EffectKind.instSup = { sup := EffectKind.sup }
Equations
- EffectKind.impure.inf EffectKind.impure = EffectKind.impure
- x✝.inf x = EffectKind.pure
Instances For
Equations
- EffectKind.instInf = { inf := EffectKind.inf }
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
def
EffectKind.liftEffect
{m : Type → Type}
[Monad m]
{e1 : EffectKind}
{e2 : EffectKind}
{α : Type}
(hle : e1 ≤ e2)
(v1 : e1.toMonad m α)
:
e2.toMonad m α
Lift a value wrapped in effect e1
into effect e2
, given that e1 ≤ e2
.
Said differently, this is a functor from the category of EffectKind (with e1 ≤ e2
as its arrows)
to Lean (with e1.toMonad x → e2.toMonad x
as its arrows).
Equations
- EffectKind.liftEffect x v1_2 = v1_2
- EffectKind.liftEffect x v1_2 = v1_2
- EffectKind.liftEffect x v1_2 = pure v1_2
Instances For
instance
EffectKind.instMonadLiftOfLe
{m : Type → Type}
{e1 : EffectKind}
{e2 : EffectKind}
(h : e1 ≤ e2)
[Monad m]
:
MonadLiftT (e1.toMonad m) (e2.toMonad m)
Equations
- EffectKind.instMonadLiftOfLe h = { monadLift := fun {α : Type} => EffectKind.liftEffect h }
instance
EffectKind.instMonadLiftTToMonadOfMonad
(eff : EffectKind)
{m : Type → Type}
[Monad m]
:
MonadLiftT (eff.toMonad m) m
Equations
- eff.instMonadLiftTToMonadOfMonad = EffectKind.instMonadLiftOfLe ⋯
@[simp]
theorem
EffectKind.liftEffect_rfl
{m : Type → Type}
{eff : EffectKind}
{α : Type}
[Monad m]
(hle : eff ≤ eff)
:
EffectKind.liftEffect hle = id
@[simp]
theorem
EffectKind.liftEffect_pure_impure
{m : Type → Type}
{α : Type}
[Monad m]
(hle : EffectKind.pure ≤ EffectKind.impure)
:
EffectKind.liftEffect hle = pure
theorem
EffectKind.liftEffect_eq_pure_cast
{α : Type}
{m : Type → Type}
[Monad m]
{eff : EffectKind}
(eff_eq : eff = EffectKind.pure)
(eff_le : eff ≤ EffectKind.impure)
:
EffectKind.liftEffect eff_le = fun (x : eff.toMonad m α) => pure (cast ⋯ x)
Forded version of liftEffect_pure_impure
@[simp]
theorem
EffectKind.liftEffect_pure
{m : Type → Type}
{α : Type}
[Monad m]
{e : EffectKind}
(hle : e ≤ EffectKind.pure)
:
EffectKind.liftEffect hle = cast ⋯
@[simp]
theorem
EffectKind.liftEffect_impure
{m : Type → Type}
{α : Type}
[Monad m]
{e : EffectKind}
(hle : e ≤ EffectKind.impure)
:
EffectKind.liftEffect hle = match (motive := (e : EffectKind) → e ≤ EffectKind.impure → e.toMonad m α → EffectKind.impure.toMonad m α) e, hle with
| EffectKind.pure, hle => fun (v : EffectKind.pure.toMonad m α) => pure v
| EffectKind.impure, hle => id
@[simp]
theorem
EffectKind.liftEffect_eq_id
{eff : EffectKind}
{m : Type → Type}
{α : Type}
(hle : eff ≤ eff)
[Monad m]
:
EffectKind.liftEffect hle = id
toMonad is functorial: it preserves identity.
def
EffectKind.liftEffect_compose
{m : Type → Type}
{e1 : EffectKind}
{e2 : EffectKind}
{e3 : EffectKind}
{α : Type}
[Monad m]
(h12 : e1 ≤ e2)
(h23 : e2 ≤ e3)
(h13 : optParam (e1 ≤ e3) ⋯)
:
toMonad is functorial: it preserves composition.
Equations
- ⋯ = ⋯