Cslib.FreeM.liftM
defimported Lean
Interpret a FreeM F computation into any monad m by providing an interpretation function for the effect signature F. This function defines the *canonical interpreter* from the free monad FreeM F into the target monad m. It is the unique monad morphism that extends the effect handler interp : ∀ {β}, F β → m β via the universal property of FreeM.
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in universe u v w w' w'' in variable {F : Type u → Type v} {ι : Type u} {α : Type w} {β : Type w'} {γ : Type w''} in variable {m : Type u → Type w} [Monad m] {α β : Type u} in protected def Cslib.FreeM.liftM (interp : {ι : Type u} → F ι → m ι) : FreeM F α → m α
- Defined in
- CSLib, `Cslib.FreeM.liftM`
- Lean proof
- By Tanner Duve, Eric Wieser, from github.com/leanprover/cslib at
3951377e5a3f(Copyright (c) 2025 Tanner Duve. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.33.0.Cslib.FreeM.liftM← Cslib.FreeM.liftM (Cslib/Foundations/Control/Monad/Free.lean:219): verbatim
- Verified
- 08 Oct 2026
- Axioms
- none listed
- Built on 7
- Cslib.FreeM.instMonadCslib.FreeM.instMonad
- Cslib.FreeM.instFunctorCslib.FreeM.instFunctor
- Cslib.FreeM.instLawfulFunctorCslib.FreeM.instLawfulFunctor
- Cslib.FreeM.instBindCslib.FreeM.instBind
- Cslib.FreeM.instLawfulMonadCslib.FreeM.instLawfulMonad
- Cslib.FreeM.instPureCslib.FreeM.instPure
- Cslib.FreeMThe Free monad over a type constructor
F. AFreeM F ais a tree of operations from the type constructorF, with leaves of typea.…
- Used by 18
- Cslib.FreeM.FreeState.toStateMConvert a
FreeStatecomputation into aStateMcomputation. This is the canonical interpreter derived fromliftM. - Cslib.FreeM.liftM_lift_bindCslib.FreeM.liftM_lift_bind
- Cslib.FreeM.liftM_seqLeftCslib.FreeM.liftM_seqLeft
- Cslib.FreeM.liftM_bindCslib.FreeM.liftM_bind
- Cslib.FreeM.Interprets.eqCslib.FreeM.Interprets.eq
- Cslib.FreeM.Interprets.liftMCslib.FreeM.Interprets.liftM
- Cslib.FreeM.liftM_seqRightCslib.FreeM.liftM_seqRight
- Cslib.FreeM.liftM_liftCslib.FreeM.liftM_lift
- Cslib.FreeM.FreeReader.toReaderMConvert a
FreeReadercomputation into aReaderMcomputation. This is the canonical interpreter derived fromliftM. - Cslib.FreeM.FreeCont.toContTConvert a
FreeContcomputation into aContTcomputation. This is the canonical interpreter derived fromliftM. - Cslib.FreeM.FreeCont.run_toContTThe canonical interpreter
toContTderived fromliftMagrees with the hand-written recursive interpreterrunforFreeCont. - Cslib.FreeM.FreeReader.run_bindCslib.FreeM.FreeReader.run_bind
- Cslib.FreeM.liftM_pureCslib.FreeM.liftM_pure
- Cslib.FreeM.liftM_seqCslib.FreeM.liftM_seq
- Cslib.FreeM.liftM_mapCslib.FreeM.liftM_map
- Cslib.FreeM.Interprets.iffThe universal property of the free monad
FreeM. That is,liftM handleris the unique interpreter that extends the effect handler… - Cslib.FreeM.FreeWriter.toWriterTConvert a
FreeWritercomputation into aWriterTcomputation. This is the canonical interpreter derived fromliftM. - Cslib.FreeM.FreeWriter.run_toWriterTThe canonical interpreter
toWriterTderived fromliftMagrees with the hand-written recursive interpreterrunforFreeWriter.
- Cslib.FreeM.FreeState.toStateMConvert a
Lean source view module on GitHub
set_option autoImplicit true in set_option relaxedAutoImplicit true in universe u v w w' w'' in variable {F : Type u → Type v} {ι : Type u} {α : Type w} {β : Type w'} {γ : Type w''} in variable {m : Type u → Type w} [Monad m] {α β : Type u} in /-- Interpret a `FreeM F` computation into any monad `m` by providing an interpretation function for the effect signature `F`. This function defines the *canonical interpreter* from the free monad `FreeM F` into the target monad `m`. It is the unique monad morphism that extends the effect handler `interp : ∀ {β}, F β → m β` via the universal property of `FreeM`. -/ protected def Cslib.FreeM.liftM (interp : {ι : Type u} → F ι → m ι) : FreeM F α → m α | .pure a => pure a | .liftBind op cont => interp op >>= fun result => (cont result).liftM interp