# Documentation

class Lean.MonadBacktrack (s : ) (m : ) :
• saveState : m s
• restoreState : sm Unit

Similar to MonadState, but it retrieves/restores only the "backtrackable" part of the state

Instances
def Lean.commitWhenSome? {m : } {s : Type} {ε : Type u_1} {α : Type} [inst : ] [inst : ] [inst : ] (x? : m ()) :
m ()

Execute x?, but backtrack state if result is none or an exception was thrown.

Equations
• One or more equations did not get rendered due to their size.
def Lean.commitWhenSomeNoEx? {m : } {s : Type} {ε : Type u_1} {α : Type} [inst : ] [inst : ] [inst : ] (x? : m ()) :
m ()

Execute x?, but backtrack state if result is none or an exception was thrown. If an exception is thrown, none is returned. That is, this function is similar to commitWhenSome?, but swallows the exception and returns none.

Equations
• One or more equations did not get rendered due to their size.
def Lean.commitWhen {m : } {s : Type} {ε : Type u_1} [inst : ] [inst : ] [inst : ] (x : m Bool) :
Equations
• One or more equations did not get rendered due to their size.
def Lean.commitIfNoEx {m : } {s : Type} {ε : Type u_1} {α : Type} [inst : ] [inst : ] [inst : ] (x : m α) :
m α
Equations
def Lean.withoutModifyingState {m : } {s : Type} {α : Type} [inst : ] [inst : ] [inst : ] (x : m α) :
m α
Equations
• = do let s ← Lean.saveState
def Lean.observing? {m : } {s : Type} {ε : Type u_1} {α : Type} [inst : ] [inst : ] [inst : ] (x : m α) :
m ()
Equations
• One or more equations did not get rendered due to their size.
instance Lean.instMonadBacktrackExceptT {s : Type} {m : } {ε : Type} [inst : ] [inst : ] :
Equations
• Lean.instMonadBacktrackExceptT = { saveState := ExceptT.lift Lean.saveState, restoreState := fun s => }