summaryrefslogtreecommitdiff
path: root/tests/fstar/betree_back_stateful
diff options
context:
space:
mode:
authorSon Ho2022-11-15 11:43:13 +0100
committerSon HO2022-11-16 15:45:32 +0100
commite4043e51ed4b4dcee7096df2d55ac049033b1d68 (patch)
tree94febfe1778ecaa3fb78eb5d40786f0f2c267581 /tests/fstar/betree_back_stateful
parent6232c2bfda2d3bbb4de8b536d8b03fe26255a864 (diff)
Make minor modifications to the extraction
Diffstat (limited to 'tests/fstar/betree_back_stateful')
-rw-r--r--tests/fstar/betree_back_stateful/Primitives.fst24
1 files changed, 14 insertions, 10 deletions
diff --git a/tests/fstar/betree_back_stateful/Primitives.fst b/tests/fstar/betree_back_stateful/Primitives.fst
index 9a06b596..bf0f9078 100644
--- a/tests/fstar/betree_back_stateful/Primitives.fst
+++ b/tests/fstar/betree_back_stateful/Primitives.fst
@@ -26,14 +26,19 @@ type result (a : Type0) : Type0 =
| Return : v:a -> result a
| Fail : e:error -> result a
-// Monadic bind and return.
-// Re-definining those allows us to customize the result of the monadic notations
-// like: `y <-- f x;`
-let return (#a : Type0) (x:a) : result a = Return x
-let bind (#a #b : Type0) (m : result a) (f : a -> result b) : result b =
- match m with
- | Return x -> f x
- | Fail e -> Fail e
+// Monadic return operator
+unfold let return (#a : Type0) (x : a) : result a = Return x
+
+// Monadic bind operator.
+// Allows to use the notation:
+// ```
+// let* x = y in
+// ...
+// ```
+unfold let (let*) (#a #b : Type0) (m: result a) (f: a -> result b) : result b =
+ match m with
+ | Return x -> f x
+ | Fail e -> Fail e
// Monadic assert(...)
let massert (b:bool) : result unit = if b then Return () else Fail Failure
@@ -52,7 +57,7 @@ let mem_replace_fwd (a : Type0) (x : a) (y : a) : a = x
let mem_replace_back (a : Type0) (x : a) (y : a) : a = y
(*** Scalars *)
-/// Rk.: most of the following code was at least partially generated
+/// Rem.: most of the following code was partially generated
let isize_min : int = -9223372036854775808 // TODO: should be opaque
let isize_max : int = 9223372036854775807 // TODO: should be opaque
@@ -291,4 +296,3 @@ let vec_index_mut_fwd (a : Type0) (v : vec a) (i : usize) : result a =
if i < length v then Return (index v i) else Fail Failure
let vec_index_mut_back (a : Type0) (v : vec a) (i : usize) (nx : a) : result (vec a) =
if i < length v then Return (list_update v i nx) else Fail Failure
-