From 001f3553287a51c1704ea3033a44e548440ec108 Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Mon, 13 May 2024 18:10:39 +0200 Subject: backends/lean: repair definition of `core.mem.replace` Oops, it is supposed to do something with the second argument! Signed-off-by: Ryan Lahfa --- backends/lean/Base/Primitives/Base.lean | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'backends/lean') diff --git a/backends/lean/Base/Primitives/Base.lean b/backends/lean/Base/Primitives/Base.lean index d682e926..c9237e65 100644 --- a/backends/lean/Base/Primitives/Base.lean +++ b/backends/lean/Base/Primitives/Base.lean @@ -134,7 +134,10 @@ def Result.attach {α: Type} (o : Result α): Result { x : α // o = ok x } := -- MISC -- ---------- -@[simp] def core.mem.replace (a : Type) (x : a) (_ : a) : a × a := (x, x) +-- This acts like a swap effectively in a functional pure world. +-- We return the old value of `dst`, i.e. `dst` itself. +-- The new value of `dst` is `src`. +@[simp] def core.mem.replace (a : Type) (dst : a) (src : a) : a × a := (dst, src) /- [core::option::Option::take] -/ @[simp] def Option.take (T: Type) (self: Option T): Option T × Option T := (self, .none) /- [core::mem::swap] -/ -- cgit v1.2.3