@[reducible, inline]
abbrev
repeatM.body
{α : Type u}
{m : Type u → Type v}
[Monad m]
{β : Type u}
(f : α → m (α ⊕ β))
(recur : α → m β)
(a : α)
:
m β
The body of repeatM: run f a, recurse via recur on .inl, return on .inr.
Equations
- repeatM.body f recur a = do let __do_lift ← f a match __do_lift with | Sum.inl a => recur a | Sum.inr b => pure b
Instances For
@[implemented_by _private.Init.While.0.repeatM.erased]
def
repeatM
{α : Type u}
{m : Type u → Type v}
[Monad m]
{β : Type u}
[Nonempty β]
(f : α → m (α ⊕ β))
(a : α)
:
m β
repeatM f a iterates f at a, recursing on .inl and terminating on .inr.
Equations
- repeatM f a = (repeatM.impl✝ f a).val
Instances For
Loop type backing repeat/while/repeat ... until #
The parsers and elaborators for repeat, while, and repeat ... until live in
Lean.Parser.Do and Lean.Elab.BuiltinDo.Repeat. This module only provides the
Loop type (and ForIn instance) that those elaborators expand to.
@[instance_reducible]
Equations
- Lean.instForInLoopUnitOfMonad = { forIn := fun {β : Type ?u.2} => Lean.Loop.forIn }