StateList
StateList
is a List with a state associated to each element.
This is used instead of List (α × σ)
as it is more efficient.
- nil: {σ α : Type u} → Mathlib.Meta.FunProp.StateList σ α
.nil is the empty list.
- cons: {σ α : Type u} → α → σ → Mathlib.Meta.FunProp.StateList σ α → Mathlib.Meta.FunProp.StateList σ α
Instances For
Equations
- Mathlib.Meta.FunProp.StateList.instAppend = { append := Mathlib.Meta.FunProp.StateList.append }
The combined state and list monad transformer.
Equations
- Mathlib.Meta.FunProp.StateListT σ m α = (σ → m (Mathlib.Meta.FunProp.StateList σ α))
Instances For
@[inline]
def
Mathlib.Meta.FunProp.StateListT.run
{α : Type u}
{σ : Type u}
{m : Type u → Type v}
[Functor m]
(x : Mathlib.Meta.FunProp.StateListT σ m α)
(s : σ)
:
Run x
on a given state s
, returning the list of values with corresponding states.
Instances For
@[inline]
def
Mathlib.Meta.FunProp.StateListT.run'
{α : Type u}
{σ : Type u}
{m : Type u → Type v}
[Functor m]
(x : Mathlib.Meta.FunProp.StateListT σ m α)
(s : σ)
:
m (List α)
Run x
on a given state s
, returning the list of values.
Instances For
@[reducible, inline]
The combined state and list monad.
Equations
Instances For
instance
Mathlib.Meta.FunProp.StateListT.instAlternative
{σ : Type u}
{m : Type u → Type v}
[Monad m]
:
Equations
- Mathlib.Meta.FunProp.StateListT.instAlternative = Alternative.mk (fun {α : Type u} => Mathlib.Meta.FunProp.StateListT.failure) fun {α : Type u} => Mathlib.Meta.FunProp.StateListT.orElse
@[inline]
Return the state from StateListT σ m
.
Equations
- Mathlib.Meta.FunProp.StateListT.get s = pure (Mathlib.Meta.FunProp.StateList.cons s s Mathlib.Meta.FunProp.StateList.nil)
Instances For
@[inline]
def
Mathlib.Meta.FunProp.StateListT.set
{σ : Type u}
{m : Type u → Type v}
[Monad m]
:
σ → Mathlib.Meta.FunProp.StateListT σ m PUnit
Set the state in StateListT σ m
.
Equations
- Mathlib.Meta.FunProp.StateListT.set s' x = pure (Mathlib.Meta.FunProp.StateList.cons PUnit.unit s' Mathlib.Meta.FunProp.StateList.nil)
Instances For
@[inline]
def
Mathlib.Meta.FunProp.StateListT.modifyGet
{α : Type u}
{σ : Type u}
{m : Type u → Type v}
[Monad m]
(f : σ → α × σ)
:
Modify and get the state in StateListT σ m
.
Equations
- Mathlib.Meta.FunProp.StateListT.modifyGet f s = let a := f s; pure (Mathlib.Meta.FunProp.StateList.cons a.fst a.snd Mathlib.Meta.FunProp.StateList.nil)
Instances For
@[inline]
def
Mathlib.Meta.FunProp.StateListT.lift
{α : Type u}
{σ : Type u}
{m : Type u → Type v}
[Monad m]
(t : m α)
:
Lift an action from m α
to StateListT σ m α
.
Equations
- Mathlib.Meta.FunProp.StateListT.lift t s = do let a ← t pure (Mathlib.Meta.FunProp.StateList.cons a s Mathlib.Meta.FunProp.StateList.nil)
Instances For
instance
Mathlib.Meta.FunProp.StateListT.instMonadLift
{σ : Type u}
{m : Type u → Type v}
[Monad m]
:
@[always_inline]
Equations
- Mathlib.Meta.FunProp.StateListT.instMonadFunctor = { monadMap := fun {α : Type u} (f : {β : Type u} → m β → m β) (x : Mathlib.Meta.FunProp.StateListT σ m α) (s : σ) => f (x s) }
@[always_inline]
instance
Mathlib.Meta.FunProp.StateListT.instMonadExceptOf
{σ : Type u}
{m : Type u → Type v}
[Monad m]
{ε : Type u_1}
[MonadExceptOf ε m]
:
Equations
- One or more equations did not get rendered due to their size.
instance
Mathlib.Meta.FunProp.instMonadStateOfStateListT
{σ : Type u}
{m : Type u → Type v}
[Monad m]
:
Equations
- One or more equations did not get rendered due to their size.
@[always_inline]
instance
Mathlib.Meta.FunProp.StateListT.monadControl
{σ : Type u}
{m : Type u → Type v}
[Monad m]
:
Equations
- One or more equations did not get rendered due to their size.