@[reducible, inline]
A sequence of calls donated by the key type κ
.
Equations
- Lake.CallStack κ = List κ
Instances For
Similar to MonadCallStackOf
, but κ
is an outParam
for convenience.
- getCallStack : m (Lake.CallStack κ)
Instances
instance
Lake.instMonadCallStackOfMonadCallStackOf
{κ : Type u_1}
{m : Type u_1 → Type u_2}
[Lake.MonadCallStackOf κ m]
:
instance
Lake.instMonadCallStackOfOfMonadLiftOfMonadFunctor
{m : Type u_1 → Type u_2}
{n : Type u_1 → Type u_3}
{κ : Type u_1}
[MonadLift m n]
[MonadFunctor m n]
[Lake.MonadCallStackOf κ m]
:
Equations
- One or more equations did not get rendered due to their size.
class
Lake.MonadCycleOf
(κ : semiOutParam (Type u))
(m : Type u → Type v)
extends Lake.MonadCallStackOf κ m :
Type (max (u + 1) v)
A monad equipped with a call stack and the ability to error on a cycle.
- getCallStack : m (Lake.CallStack κ)
Instances
class
Lake.MonadCycle
(κ : outParam (Type u))
(m : Type u → Type v)
extends Lake.MonadCallStack κ m :
Type (max (u + 1) v)
Similar to MonadCycle
, but κ
is an outParam
for convenience.
- getCallStack : m (Lake.CallStack κ)
Instances
instance
Lake.instMonadCycleOfMonadCycleOf
{κ : Type u_1}
{m : Type u_1 → Type u_2}
[Lake.MonadCycleOf κ m]
:
Lake.MonadCycle κ m
Equations
- Lake.instMonadCycleOfMonadCycleOf = Lake.MonadCycle.mk fun {α : Type ?u.27} => Lake.MonadCycleOf.throwCycle
instance
Lake.instMonadCycleOfOfMonadLiftOfMonadFunctor
{m : Type u_1 → Type u_2}
{n : Type u_1 → Type u_3}
{κ : Type u_1}
[MonadLift m n]
[MonadFunctor m n]
[Lake.MonadCycleOf κ m]
:
Equations
- Lake.instMonadCycleOfOfMonadLiftOfMonadFunctor = Lake.MonadCycleOf.mk fun {α : Type ?u.45} (cycle : Lake.Cycle κ) => liftM (Lake.throwCycle cycle)
instance
Lake.inhabitedOfMonadCycle
{κ : Type u_1}
{m : Type u_1 → Type u_2}
{α : Type u_1}
[Lake.MonadCycle κ m]
:
Inhabited (m α)
Equations
- Lake.inhabitedOfMonadCycle = { default := Lake.throwCycle [] }
@[reducible, inline]
A transformer that equips a monad with a CallStack
.
Equations
- Lake.CallStackT κ m = ReaderT (Lake.CallStack κ) m
Instances For
instance
Lake.instMonadCallStackOfCallStackTOfMonad
{m : Type u_1 → Type u_2}
{κ : Type u_1}
[Monad m]
:
Lake.MonadCallStackOf κ (Lake.CallStackT κ m)
Equations
- Lake.instMonadCallStackOfCallStackTOfMonad = { getCallStack := read, withCallStack := fun {α : Type ?u.30} (s : Lake.CallStack κ) (x : Lake.CallStackT κ m α) => liftM (x s) }
@[reducible, inline]
A transformer that equips a monad with a CallStack
to detect cycles.
Equations
- Lake.CycleT κ m = Lake.CallStackT κ (ExceptT (Lake.Cycle κ) m)
Instances For
instance
Lake.instMonadCycleOfCycleTOfMonad
{m : Type u_1 → Type u_2}
{κ : Type u_1}
[Monad m]
:
Lake.MonadCycleOf κ (Lake.CycleT κ m)
Equations
- Lake.instMonadCycleOfCycleTOfMonad = Lake.MonadCycleOf.mk fun {α : Type ?u.28} => throw
@[inline]
def
Lake.guardCycle
{κ : Type u_1}
{m : Type u_1 → Type u_2}
{α : Type u_1}
[BEq κ]
[Monad m]
[Lake.MonadCycle κ m]
(key : κ)
(act : m α)
:
m α
Add key
to the monad's CallStack
before invoking act
.
If adding key
produces a cycle, the cyclic call stack is thrown.
Equations
- One or more equations did not get rendered due to their size.