File: .lake/packages/lean4/src/lean/Init/Control/Basic.lean

full_name: Functor.mapRev
code: @[reducible]
def Functor.mapRev {f : Type u → Type v} [Functor f] {α β : Type u} : f α → (α → β) → f β 
goal: f α → (α → β) → f β

full_name: «_aux_.lake_packages_lean4_src_lean_Init_Control_Basic___macroRules_term_<&>__1»
code: infixr:100 " <&> " => Functor.mapRev
goal: Lean.Macro

full_name: «_aux_.lake_packages_lean4_src_lean_Init_Control_Basic___unexpand_Functor_mapRev_1»
code: infixr:100 " <&> " => Functor.mapRev
goal: Lean.PrettyPrinter.Unexpander

full_name: Functor.discard
code: @[always_inline, inline]
def Functor.discard {f : Type u → Type v} {α : Type u} [Functor f] (x : f α) : f PUnit 
goal: f PUnit

full_name: Alternative.orElse
code: /--
An `Alternative` functor is an `Applicative` functor that can "fail" or be "empty"
and a binary operation `<|>` that “collects values” or finds the “left-most success”.

Important instances include
* `Option`, where `failure := none` and `<|>` returns the left-most `some`.
* Parser combinators typically provide an `Applicative` instance for error-handling and
  backtracking.
  
Error recovery and state can interact subtly. For example, the implementation of `Alternative` for `OptionT (StateT σ Id)` keeps modifications made to the state while recovering from failure, while `StateT σ (OptionT Id)` discards them.
-/
-- NB: List instance is in mathlib. Once upstreamed, add
-- * `List`, where `failure` is the empty list and `<|>` concatenates.
class Alternative (f : Type u → Type v) extends Applicative f : Type (max (u+1) v) where
  /--
  Produces an empty collection or recoverable failure.  The `<|>` operator collects values or recovers
  from failures. See `Alternative` for more details.
  -/
  failure : {α : Type u} → f α
  /--
  Depending on the `Alternative` instance, collects values or recovers from `failure`s by
  returning the leftmost success. Can be written using the `<|>` operator syntax.
  -/
  orElse  : {α : Type u} → f α → (Unit → f α) → f α
goal: f α → (Unit → f α) → f α

full_name: Alternative
code: /--
An `Alternative` functor is an `Applicative` functor that can "fail" or be "empty"
and a binary operation `<|>` that “collects values” or finds the “left-most success”.

Important instances include
* `Option`, where `failure := none` and `<|>` returns the left-most `some`.
* Parser combinators typically provide an `Applicative` instance for error-handling and
  backtracking.
  
Error recovery and state can interact subtly. For example, the implementation of `Alternative` for `OptionT (StateT σ Id)` keeps modifications made to the state while recovering from failure, while `StateT σ (OptionT Id)` discards them.
-/
-- NB: List instance is in mathlib. Once upstreamed, add
-- * `List`, where `failure` is the empty list and `<|>` concatenates.
class Alternative (f : Type u → Type v) extends Applicative f : Type (max (u+1) v) where
  /--
  Produces an empty collection or recoverable failure.  The `<|>` operator collects values or recovers
  from failures. See `Alternative` for more details.
  -/
  failure : {α : Type u} → f α
  /--
  Depending on the `Alternative` instance, collects values or recovers from `failure`s by
  returning the leftmost success. Can be written using the `<|>` operator syntax.
  -/
  orElse  : {α : Type u} → f α → (Unit → f α) → f α
goal: Type (max (u + 1) v)

full_name: Alternative.failure
code: /--
An `Alternative` functor is an `Applicative` functor that can "fail" or be "empty"
and a binary operation `<|>` that “collects values” or finds the “left-most success”.

Important instances include
* `Option`, where `failure := none` and `<|>` returns the left-most `some`.
* Parser combinators typically provide an `Applicative` instance for error-handling and
  backtracking.
  
Error recovery and state can interact subtly. For example, the implementation of `Alternative` for `OptionT (StateT σ Id)` keeps modifications made to the state while recovering from failure, while `StateT σ (OptionT Id)` discards them.
-/
-- NB: List instance is in mathlib. Once upstreamed, add
-- * `List`, where `failure` is the empty list and `<|>` concatenates.
class Alternative (f : Type u → Type v) extends Applicative f : Type (max (u+1) v) where
  /--
  Produces an empty collection or recoverable failure.  The `<|>` operator collects values or recovers
  from failures. See `Alternative` for more details.
  -/
  failure : {α : Type u} → f α
  /--
  Depending on the `Alternative` instance, collects values or recovers from `failure`s by
  returning the leftmost success. Can be written using the `<|>` operator syntax.
  -/
  orElse  : {α : Type u} → f α → (Unit → f α) → f α
goal: f α

full_name: instOrElseOfAlternative
code: instance (f : Type u → Type v) (α : Type u) [Alternative f] : OrElse (f α) 
goal: OrElse (f α)

full_name: guard
code: /--
If the proposition `p` is true, does nothing, else fails (using `failure`).
-/
@[always_inline, inline] def guard {f : Type → Type v} [Alternative f] (p : Prop) [Decidable p] : f Unit 
goal: f Unit

full_name: optional
code: /--
Returns `some x` if `f` succeeds with value `x`, else returns `none`.
-/
@[always_inline, inline] def optional (x : f α) : f (Option α) 
goal: f (Option α)

full_name: ToBool
code: class ToBool (α : Type u) where
  toBool : α → Bool
goal: Type u

full_name: ToBool.toBool
code: class ToBool (α : Type u) where
  toBool : α → Bool
goal: α → Bool

full_name: instToBoolBool
code: instance : ToBool Bool 
goal: ToBool Bool

full_name: bool
code: @[macro_inline] def bool {β : Type u} {α : Type v} [ToBool β] (f t : α) (b : β) : α 
goal: α

full_name: orM
code: @[macro_inline] def orM {m : Type u → Type v} {β : Type u} [Monad m] [ToBool β] (x y : m β) : m β 
goal: m β

full_name: «_aux_.lake_packages_lean4_src_lean_Init_Control_Basic___macroRules_term_<||>__1»
code: infixr:30 " <||> " => orM
goal: Lean.Macro

full_name: «_aux_.lake_packages_lean4_src_lean_Init_Control_Basic___unexpand_orM_1»
code: infixr:30 " <||> " => orM
goal: Lean.PrettyPrinter.Unexpander

full_name: andM
code: @[macro_inline] def andM {m : Type u → Type v} {β : Type u} [Monad m] [ToBool β] (x y : m β) : m β 
goal: m β

full_name: «_aux_.lake_packages_lean4_src_lean_Init_Control_Basic___unexpand_andM_1»
code: infixr:35 " <&&> " => andM
goal: Lean.PrettyPrinter.Unexpander

full_name: «_aux_.lake_packages_lean4_src_lean_Init_Control_Basic___macroRules_term_<&&>__1»
code: infixr:35 " <&&> " => andM
goal: Lean.Macro

full_name: notM
code: @[macro_inline] def notM {m : Type → Type v} [Applicative m] (x : m Bool) : m Bool 
goal: m Bool

full_name: MonadControl.stM
code: /-- MonadControl is a way of stating that the monad `m` can be 'run inside' the monad `n`.

This is the same as [`MonadBaseControl`](https://hackage.haskell.org/package/monad-control-1.0.3.1/docs/Control-Monad-Trans-Control.html#t:MonadBaseControl) in Haskell.
To learn about `MonadControl`, see the comment above this docstring.

-/
class MonadControl (m : semiOutParam (Type u → Type v)) (n : Type u → Type w) where
  stM      : Type u → Type u
  liftWith : {α : Type u} → (({β : Type u} → n β → m (stM β)) → m α) → n α
  restoreM : {α : Type u} → m (stM α) → n α
goal: Type u → Type u

full_name: MonadControl
code: /-- MonadControl is a way of stating that the monad `m` can be 'run inside' the monad `n`.

This is the same as [`MonadBaseControl`](https://hackage.haskell.org/package/monad-control-1.0.3.1/docs/Control-Monad-Trans-Control.html#t:MonadBaseControl) in Haskell.
To learn about `MonadControl`, see the comment above this docstring.

-/
class MonadControl (m : semiOutParam (Type u → Type v)) (n : Type u → Type w) where
  stM      : Type u → Type u
  liftWith : {α : Type u} → (({β : Type u} → n β → m (stM β)) → m α) → n α
  restoreM : {α : Type u} → m (stM α) → n α
goal: Type (max (max (u + 1) v) w)

full_name: MonadControl.restoreM
code: /-- MonadControl is a way of stating that the monad `m` can be 'run inside' the monad `n`.

This is the same as [`MonadBaseControl`](https://hackage.haskell.org/package/monad-control-1.0.3.1/docs/Control-Monad-Trans-Control.html#t:MonadBaseControl) in Haskell.
To learn about `MonadControl`, see the comment above this docstring.

-/
class MonadControl (m : semiOutParam (Type u → Type v)) (n : Type u → Type w) where
  stM      : Type u → Type u
  liftWith : {α : Type u} → (({β : Type u} → n β → m (stM β)) → m α) → n α
  restoreM : {α : Type u} → m (stM α) → n α
goal: m (MonadControl.stM m n α) → n α

full_name: MonadControl.liftWith
code: /-- MonadControl is a way of stating that the monad `m` can be 'run inside' the monad `n`.

This is the same as [`MonadBaseControl`](https://hackage.haskell.org/package/monad-control-1.0.3.1/docs/Control-Monad-Trans-Control.html#t:MonadBaseControl) in Haskell.
To learn about `MonadControl`, see the comment above this docstring.

-/
class MonadControl (m : semiOutParam (Type u → Type v)) (n : Type u → Type w) where
  stM      : Type u → Type u
  liftWith : {α : Type u} → (({β : Type u} → n β → m (stM β)) → m α) → n α
  restoreM : {α : Type u} → m (stM α) → n α
goal: (({β : Type u} → n β → m (MonadControl.stM m n β)) → m α) → n α

full_name: MonadControlT.liftWith
code: /-- Transitive closure of MonadControl. -/
class MonadControlT (m : Type u → Type v) (n : Type u → Type w) where
  stM      : Type u → Type u
  liftWith : {α : Type u} → (({β : Type u} → n β → m (stM β)) → m α) → n α
  restoreM {α : Type u} : stM α → n α
goal: (({β : Type u} → n β → m (stM m n β)) → m α) → n α

full_name: MonadControlT.restoreM
code: /-- Transitive closure of MonadControl. -/
class MonadControlT (m : Type u → Type v) (n : Type u → Type w) where
  stM      : Type u → Type u
  liftWith : {α : Type u} → (({β : Type u} → n β → m (stM β)) → m α) → n α
  restoreM {α : Type u} : stM α → n α
goal: stM m n α → n α

full_name: MonadControlT
code: /-- Transitive closure of MonadControl. -/
class MonadControlT (m : Type u → Type v) (n : Type u → Type w) where
  stM      : Type u → Type u
  liftWith : {α : Type u} → (({β : Type u} → n β → m (stM β)) → m α) → n α
  restoreM {α : Type u} : stM α → n α
goal: Type (max (max (u + 1) v) w)

full_name: MonadControlT.stM
code: /-- Transitive closure of MonadControl. -/
class MonadControlT (m : Type u → Type v) (n : Type u → Type w) where
  stM      : Type u → Type u
  liftWith : {α : Type u} → (({β : Type u} → n β → m (stM β)) → m α) → n α
  restoreM {α : Type u} : stM α → n α
goal: Type u → Type u

full_name: instMonadControlTOfMonadControl
code: @[always_inline]
instance (m n o) [MonadControl n o] [MonadControlT m n] : MonadControlT m o 
goal: MonadControlT m o

full_name: instMonadControlTOfPure
code: instance (m : Type u → Type v) [Pure m] : MonadControlT m m 
goal: MonadControlT m m

full_name: controlAt
code: @[always_inline, inline]
def controlAt (m : Type u → Type v) {n : Type u → Type w} [MonadControlT m n] [Bind n] {α : Type u}
    (f : ({β : Type u} → n β → m (stM m n β)) → m (stM m n α)) : n α 
goal: n α

full_name: control
code: @[always_inline, inline]
def control {m : Type u → Type v} {n : Type u → Type w} [MonadControlT m n] [Bind n] {α : Type u}
    (f : ({β : Type u} → n β → m (stM m n β)) → m (stM m n α)) : n α 
goal: n α

full_name: ForM
code: /--
  Typeclass for the polymorphic `forM` operation described in the "do unchained" paper.
  Remark:
  - `γ` is a "container" type of elements of type `α`.
  - `α` is treated as an output parameter by the typeclass resolution procedure.
    That is, it tries to find an instance using only `m` and `γ`.
-/
class ForM (m : Type u → Type v) (γ : Type w₁) (α : outParam (Type w₂)) where
  forM [Monad m] : γ → (α → m PUnit) → m PUnit
goal: Type (max (max (max (u + 1) v) w₁) w₂)

full_name: ForM.forM
code: /--
  Typeclass for the polymorphic `forM` operation described in the "do unchained" paper.
  Remark:
  - `γ` is a "container" type of elements of type `α`.
  - `α` is treated as an output parameter by the typeclass resolution procedure.
    That is, it tries to find an instance using only `m` and `γ`.
-/
class ForM (m : Type u → Type v) (γ : Type w₁) (α : outParam (Type w₂)) where
  forM [Monad m] : γ → (α → m PUnit) → m PUnit
goal: γ → (α → m PUnit) → m PUnit

full_name: Bind.kleisliRight
code: /-- Left-to-right composition of Kleisli arrows. -/
@[always_inline]
def Bind.kleisliRight [Bind m] (f₁ : α → m β) (f₂ : β → m γ) (a : α) : m γ 
goal: m γ

full_name: Bind.kleisliLeft
code: /-- Right-to-left composition of Kleisli arrows. -/
@[always_inline]
def Bind.kleisliLeft [Bind m] (f₂ : β → m γ) (f₁ : α → m β) (a : α) : m γ 
goal: m γ

full_name: Bind.bindLeft
code: /-- Same as `Bind.bind` but with arguments swapped. -/
@[always_inline]
def Bind.bindLeft [Bind m] (f : α → m β) (ma : m α) : m β 
goal: m β

full_name: «_aux_.lake_packages_lean4_src_lean_Init_Control_Basic___macroRules_term_>=>__1»
code: @[inherit_doc] infixr:55 " >=> " => Bind.kleisliRight
goal: Lean.Macro

full_name: «_aux_.lake_packages_lean4_src_lean_Init_Control_Basic___unexpand_Bind_kleisliRight_1»
code: @[inherit_doc] infixr:55 " >=> " => Bind.kleisliRight
goal: Lean.PrettyPrinter.Unexpander

full_name: «_aux_.lake_packages_lean4_src_lean_Init_Control_Basic___unexpand_Bind_kleisliLeft_1»
code: @[inherit_doc] infixr:55 " <=< " => Bind.kleisliLeft
goal: Lean.PrettyPrinter.Unexpander

full_name: «_aux_.lake_packages_lean4_src_lean_Init_Control_Basic___macroRules_term_<=<__1»
code: @[inherit_doc] infixr:55 " <=< " => Bind.kleisliLeft
goal: Lean.Macro

full_name: «_aux_.lake_packages_lean4_src_lean_Init_Control_Basic___unexpand_Bind_bindLeft_1»
code: @[inherit_doc] infixr:55 " =<< " => Bind.bindLeft
goal: Lean.PrettyPrinter.Unexpander

full_name: «_aux_.lake_packages_lean4_src_lean_Init_Control_Basic___macroRules_term_=<<__1»
code: @[inherit_doc] infixr:55 " =<< " => Bind.bindLeft
goal: Lean.Macro