@@ -216,13 +216,37 @@ lemma liftM_lift [LawfulMonad m] (interp : {ι : Type u} → F ι → m ι) (op
216216@[simp]
217217lemma liftM_bind [LawfulMonad m]
218218 (interp : {ι : Type u} → F ι → m ι) (x : FreeM F α) (f : α → FreeM F β) :
219- (x.bind f : FreeM F β ).liftM interp = (do let a ← x.liftM interp; (f a).liftM interp) := by
219+ (x.bind f).liftM interp = (do let a ← x.liftM interp; (f a).liftM interp) := by
220220 induction x generalizing f with
221221 | pure a => simp only [pure_bind, liftM_pure, LawfulMonad.pure_bind]
222222 | liftBind op cont ih =>
223223 rw [FreeM.bind, liftM_liftBind, liftM_liftBind, bind_assoc]
224224 simp_rw [ih]
225225
226+ @[simp]
227+ lemma liftM_map [LawfulMonad m]
228+ (interp : {ι : Type u} → F ι → m ι) (f : α → β) (x : FreeM F α) :
229+ (x.map f).liftM interp = f <$> x.liftM interp := by
230+ simp_rw [← bind_pure_comp, ← LawfulMonad.bind_pure_comp, liftM_bind, Function.comp, liftM_pure]
231+
232+ @[simp]
233+ lemma liftM_seq [LawfulMonad m]
234+ (interp : {ι : Type u} → F ι → m ι) (x : FreeM F (α → β)) (y : FreeM F α) :
235+ (x <*> y).liftM interp = x.liftM interp <*> y.liftM interp := by
236+ simp [seq_eq_bind_map]
237+
238+ @[simp]
239+ lemma liftM_seqLeft [LawfulMonad m]
240+ (interp : {ι : Type u} → F ι → m ι) (x : FreeM F α) (y : FreeM F β) :
241+ (x <* y).liftM interp = x.liftM interp <* y.liftM interp := by
242+ simp [seqLeft_eq_bind]
243+
244+ @[simp]
245+ lemma liftM_seqRight [LawfulMonad m]
246+ (interp : {ι : Type u} → F ι → m ι) (x : FreeM F α) (y : FreeM F β) :
247+ (x *> y).liftM interp = x.liftM interp *> y.liftM interp := by
248+ simp [seqRight_eq_bind]
249+
226250/--
227251A predicate stating that `interp : FreeM F α → m α` is an interpreter for the effect
228252handler `handler : ∀ {α}, F α → m α`.
0 commit comments