Functor Laws, applicative laws, and monad Laws #
StateT
doesn't require a constructor, but it appears confusing to declare the
following theorem as a simp theorem.
@[simp]
theorem run_fun (f : σ → m (α × σ)) (st : σ) : StateT.run (fun s => f s) st = f st :=
rfl
If we declare this theorem as a simp theorem, StateT.run f st
is simplified to f st
by eta
reduction. This breaks the structure of StateT
.
So, we declare a constructor-like definition StateT.mk
and a simp theorem for it.
Instances For
A copy of LawfulFunctor.map_const
for StateT
that holds even if m
is not lawful.
ReaderT
doesn't require a constructor, but it appears confusing to declare the
following theorem as a simp theorem.
@[simp]
theorem run_fun (f : σ → m α) (r : σ) : ReaderT.run (fun r' => f r') r = f r :=
rfl
If we declare this theorem as a simp theorem, ReaderT.run f st
is simplified to f st
by eta
reduction. This breaks the structure of ReaderT
.
So, we declare a constructor-like definition ReaderT.mk
and a simp theorem for it.
Equations
- ReaderT.mk f = f