Cslib.FreeM.Interprets
structureimported Lean
A predicate stating that interp : FreeM F α → m α is an interpreter for the effect handler handler : ∀ {α}, F α → m α. This means that interp is a monad morphism from the free monad FreeM F to the monad m, and that it extends the interpretation of individual operations given by f. Formally, interp satisfies the two equations: - interp (pure a) = pure a - interp (liftBind op k) = handler op >>= fun x => interp (k x)
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 structure Cslib.FreeM.Interprets (handler : {ι : Type u} → F ι → m ι) (interp : FreeM F α → m α) : Prop
- Defined in
- CSLib, `Cslib.FreeM.Interprets`
- 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.Interprets← Cslib.FreeM.Interprets (Cslib/Foundations/Control/Monad/Free.lean:282): verbatim
- Verified
- 08 Oct 2026
- Axioms
- none listed
- Built on 26
- Cslib.FreeM.liftM_seqLeftCslib.FreeM.liftM_seqLeft
- Cslib.FreeM.liftM_bindCslib.FreeM.liftM_bind
- Cslib.FreeM.liftM_seqRightCslib.FreeM.liftM_seqRight
- Cslib.FreeM.liftM_liftCslib.FreeM.liftM_lift
- Cslib.FreeM.liftM_seqCslib.FreeM.liftM_seq
- Cslib.FreeM.liftM_mapCslib.FreeM.liftM_map
- Cslib.FreeMThe Free monad over a type constructor
F. AFreeM F ais a tree of operations from the type constructorF, with leaves of typea.… - Cslib.FreeM.instBindCslib.FreeM.instBind
- Cslib.FreeM.liftLift an operation from the effect signature
Finto theFreeM Fmonad. - Cslib.FreeM.pure_eq_pureCslib.FreeM.pure_eq_pure
- Cslib.FreeM.bind_eq_bindNote that this lemma does not always apply, as it is universe-constrained by
Bind.bind. - Cslib.FreeM.map_eq_mapNote that this lemma does not always apply, as it is universe-constrained by
Functor.map. - Cslib.FreeM.liftBind_eqCslib.FreeM.liftBind_eq
- Cslib.FreeM.pure_bind
.pure afollowed bybindcollapses immediately. - Cslib.FreeM.bind_pureCslib.FreeM.bind_pure
- Cslib.FreeM.bind_pure_compCslib.FreeM.bind_pure_comp
- Cslib.FreeM.map_pureCslib.FreeM.map_pure
- Cslib.FreeM.map_bindCslib.FreeM.map_bind
- Cslib.FreeM.id_mapCslib.FreeM.id_map
- Cslib.FreeM.liftM_pureCslib.FreeM.liftM_pure
- Cslib.FreeM.liftM_lift_bindCslib.FreeM.liftM_lift_bind
- Cslib.FreeM.instPureCslib.FreeM.instPure
- Cslib.FreeM.instFunctorCslib.FreeM.instFunctor
- Cslib.FreeM.instLawfulFunctorCslib.FreeM.instLawfulFunctor
- Cslib.FreeM.instMonadCslib.FreeM.instMonad
- Cslib.FreeM.instLawfulMonadCslib.FreeM.instLawfulMonad
- Used by 7
- Cslib.FreeM.FreeCont.toContT_unique
toContTis the unique interpreter extendingcontInterp. - Cslib.FreeM.Interprets.eqCslib.FreeM.Interprets.eq
- Cslib.FreeM.Interprets.liftMCslib.FreeM.Interprets.liftM
- Cslib.FreeM.FreeState.toStateM_unique
toStateMis the unique interpreter extendingstateInterp. - Cslib.FreeM.FreeReader.toReaderM_unique
toReaderMis the unique interpreter extendingreadInterp. - 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.toWriterT_unique
toWriterTis the unique interpreter extendingwriterInterp.
- Cslib.FreeM.FreeCont.toContT_unique
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 /-- A predicate stating that `interp : FreeM F α → m α` is an interpreter for the effect handler `handler : ∀ {α}, F α → m α`. This means that `interp` is a monad morphism from the free monad `FreeM F` to the monad `m`, and that it extends the interpretation of individual operations given by `f`. Formally, `interp` satisfies the two equations: - `interp (pure a) = pure a` - `interp (liftBind op k) = handler op >>= fun x => interp (k x)` -/ structure Cslib.FreeM.Interprets (handler : {ι : Type u} → F ι → m ι) (interp : FreeM F α → m α) : Prop where apply_pure (a : α) : interp (.pure a) = pure a apply_lift_bind {ι : Type u} (op : F ι) (cont : ι → FreeM F α) : interp (lift op >>= cont) = handler op >>= fun x => interp (cont x)