summaryrefslogtreecommitdiff
path: root/backends/lean/Base/Primitives/Base.lean
diff options
context:
space:
mode:
authorSon HO2024-04-26 10:55:47 +0200
committerGitHub2024-04-26 10:55:47 +0200
commit5da597289c1723aa59bf87ad5075675820c18f73 (patch)
treed63e2f44c75634674a3e4eabb57ff08c0ae441ac /backends/lean/Base/Primitives/Base.lean
parent2df6dd65b84a2fd9aad4f716f323bf3f85bf82db (diff)
parentfe8d14cd8b7ba907d5248d574619e93e6d1d253a (diff)
Merge pull request #125 from zhassan-aws/core-option-unwrap
Add `core::option::unwrap` builtin
Diffstat (limited to 'backends/lean/Base/Primitives/Base.lean')
-rw-r--r--backends/lean/Base/Primitives/Base.lean5
1 files changed, 5 insertions, 0 deletions
diff --git a/backends/lean/Base/Primitives/Base.lean b/backends/lean/Base/Primitives/Base.lean
index 94134d86..d682e926 100644
--- a/backends/lean/Base/Primitives/Base.lean
+++ b/backends/lean/Base/Primitives/Base.lean
@@ -76,6 +76,11 @@ def eval_global {α: Type u} (x: Result α) (_: ok? x := by prove_eval_global) :
| fail _ | div => by contradiction
| ok x => x
+def Result.ofOption {a : Type u} (x : Option a) (e : Error) : Result a :=
+ match x with
+ | some x => ok x
+ | none => fail e
+
/- DO-DSL SUPPORT -/
def bind {α : Type u} {β : Type v} (x: Result α) (f: α → Result β) : Result β :=