Structures · Lean core
Monad
[Monads](https://en.wikipedia.org/wiki/Monad_(functional_programming)) are an abstraction of
sequential control flow and side effects used in functional programming. Monads allow both
sequencing of effects and data-dependent effects: the values that result from an early step may
influence the effects carried out in a later step.
The Monad API may be used directly. However, it is most commonly accessed through
[do-notation](https://lean-lang.org/doc/reference/4.33.0/find/?domain=Verso.Genre.Manual.section&name=do-notation).
Most Monad instances provide implementations of pure and bind, and use default implementations
for the other methods inherited from Applicative. Monads should satisfy certain laws, but
instances are not required to prove this. An instance of LawfulMonad expresses that a given
monad's operations are lawful.
- Defined in
- Init.Prelude
- Shape
- One type argument
Extends2
Extended by1
Forgetful instances
Every Monad is also a
Concrete types that are instances66
- FreeAbelianGroup
- FreeGroup
- FreeAddGroup
- MvPolynomial
- Part
- ReaderT
- StateT
- Except
- StateRefT'
- OptionT
- Ultrafilter
- Lean.Core.CoreM
- ExceptT
- Lean.Elab.Command.CommandElabM
- Semiquot
- PFun
- FreeMagma
- EStateM
- FreeSemigroup
- EIO
- Lean.Elab.Term.TermElabM
- FreeAddMagma
- Lean.Meta.MetaM
- FreeAddSemigroup
- ST
- Computation
- Std.Async.ContextAsync
- EST
- BaseIO
- Stream'.Seq1
- Std.Internal.Do.PredTrans
- Std.Iterators.PostconditionT
- Erased
- Lean.Elab.Tactic.TacticM
- Lean.MonadCacheT
- Std.Do.PredTrans
- ContT
- WriterT
- Std.Iterators.HetT
- Stream'.WSeq
- Std.Async.EAsync
- PMF
- ExceptCpsT
- StateCpsT
- Std.Internal.Parsec
- Lean.Elab.Tactic.Grind.GrindTacticM
- Std.Async.BaseAsync
- Std.Iterators.ULiftT
- Lean.MonadStateCacheT
- Std.Async.MaybeTask
- Aesop.TreeM
- Std.Async.ETask
- Aesop.SearchM
- Aesop.ElabM
- Aesop.EqualUpToIdsM
- ULift
- Sum
- List
- WithZero
- Multiset
- Finset
- Option
- PLift
- WithOne
- Id
- Trunc
How is a type an instance?
Loading the hierarchy index…
Assumed by181
- CategoryTheory.ofTypeMonad
- joinM
- CategoryTheory.kleisliCatEquivKleisli
- List.Vector.mOfFn
- Monoid.foldrM.ofFreeMonoid
- WriterT.monad
- Monoid.foldlM.ofFreeMonoid
- OptionT.mkLabel
- Traversable.foldrm
- List.mapIdxMAux'
- Monoid.foldrM
- Traversable.foldlm
- Monoid.foldlM
- List.Vector.mmap
- OptionT.callCC
- WriterT.liftTell
- List.mapIdxMAux'_eq_mapIdxMGo
- WriterT.mkLabel
- Monoid.foldrM.get
- Traversable.foldrm.ofFreeMonoid_comp_of
- ExceptT.mkLabel
- List.Vector.mOfFn_pure
- WriterT.mkLabel'
- Monoid.foldlM.get
- List.mapIdxM'
- Traversable.foldlm.ofFreeMonoid_comp_of
- map_eq_bind_pure_comp
- Random.instBoundedRandomNat
- CategoryTheory.kleisliCatEquivKleisli_unitIso
- CategoryTheory.kleisliCatEquivKleisli_functor_map_of
- Mathlib.Tactic.BicategoryLike.NormalExpr.rightUnitorInvM
- joinM_map_map
- WriterT.run_map
- condM
- Lean.Elab.Tactic.iterateAtMost
- List.Vector.mmap_cons
- Lean.Elab.Tactic.iterateRange
- Mathlib.Tactic.BicategoryLike.MonadMor₂Iso.rightUnitorM'
- Mathlib.Tactic.BicategoryLike.HorizontalComp.tgtM
- CategoryTheory.KleisliCat.id_def
- Mathlib.Tactic.BicategoryLike.NormalExpr.idM
- Mathlib.Meta.FunProp.ppOrigin
- ULiftable.adaptDown
- joinM_pure
- List.mapIdxM'_eq_mapIdxM
- Lean.Expr.modifyArgM
- List.foldrM_eq_foldr
- Mathlib.Tactic.BicategoryLike.Mor₂Iso.tgtM
- instLawfulMonadContExceptT
- Mathlib.Linter.getAliasSyntax