lean4-htt/Lake/Util/EStateT.lean

22 lines
684 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-
Copyright (c) 2022 Mac Malone. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mac Malone
-/
namespace Lake
/-- An exception plus state monad transformer (ι.e., `ExceptT` + `StateT`). -/
abbrev EStateT.{u,v} (ε : Type u) (σ : Type u) (m : Type u → Type v) :=
ExceptT ε <| StateT σ m
namespace EStateT
variable {ε : Type u} {σ : Type u} {m : Type u → Type v}
@[inline] def run (init : σ) (self : EStateT ε σ m ω) : m (Except ε ω × σ) :=
ExceptT.run self |>.run init
@[inline] def run' [Functor m] (init : σ) (self : EStateT ε σ m ω) : m (Except ε ω) :=
ExceptT.run self |>.run' init
end EStateT