Skip to content

Commit

Permalink
chore: remove explicit universes from EStateM results (#1130)
Browse files Browse the repository at this point in the history
Co-authored-by: François G. Dorais <[email protected]>
  • Loading branch information
eric-wieser and fgdorais authored Feb 15, 2025
1 parent 39208b1 commit 327d6ed
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Batteries/Lean/EStateM.lean
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ namespace EStateM
namespace Result

/-- Map a function over an `EStateM.Result`, preserving states and errors. -/
def map {ε σ α β : Type u} (f : α → β) (x : Result ε σ α) : Result ε σ β :=
def map {ε σ α β} (f : α → β) (x : Result ε σ α) : Result ε σ β :=
match x with
| .ok a s' => .ok (f a) s'
| .error e s' => .error e s'

@[simp] theorem map_ok {ε σ α β : Type u} (f : α → β) (a : α) (s : σ) :
@[simp] theorem map_ok {ε σ α β} (f : α → β) (a : α) (s : σ) :
(Result.ok a s : Result ε σ α).map f = .ok (f a) s := rfl

@[simp] theorem map_error {ε σ α β : Type u} (f : α → β) (e : ε) (s : σ) :
@[simp] theorem map_error {ε σ α β} (f : α → β) (e : ε) (s : σ) :
(Result.error e s : Result ε σ α).map f = .error e s := rfl

@[simp] theorem map_eq_ok {ε σ α β : Type u} (f : α → β) (x : Result ε σ α) (b : β) (s : σ) :
@[simp] theorem map_eq_ok {ε σ α β} {f : α → β} {x : Result ε σ α} {b : β} {s : σ} :
x.map f = .ok b s ↔ ∃ a, x = .ok a s ∧ b = f a := by
cases x <;> simp [and_assoc, and_comm, eq_comm]

@[simp] theorem map_eq_error {ε σ α β : Type u} (f : α → β) (x : Result ε σ α) (e : ε) (s : σ) :
@[simp] theorem map_eq_error {ε σ α β} (f : α → β) {x : Result ε σ α} {e : ε} {s : σ} :
x.map f = .error e s ↔ x = .error e s := by
cases x <;> simp [eq_comm]

Expand All @@ -33,7 +33,7 @@ end Result
@[simp] theorem run_map (f : α → β) (x : EStateM ε σ α) :
(f <$> x).run s = (x.run s).map f := rfl

@[ext] theorem ext {ε σ α : Type u} (x y : EStateM ε σ α) (h : ∀ s, x.run s = y.run s) : x = y := by
@[ext] theorem ext {ε σ α} {x y : EStateM ε σ α} (h : ∀ s, x.run s = y.run s) : x = y := by
funext s
exact h s

Expand Down

0 comments on commit 327d6ed

Please sign in to comment.