aboutsummaryrefslogtreecommitdiff
path: root/lib/future.ml
diff options
context:
space:
mode:
authorgareuselesinge2013-09-30 16:09:50 +0000
committergareuselesinge2013-09-30 16:09:50 +0000
commit7f948efa4b8910037a053f7ab2a2f535b85e13c4 (patch)
treedde9e3a63136c1ddb92dade93ad2c08636cc5493 /lib/future.ml
parente10fc82c4a608e3433948c9511d9edf87903b5e5 (diff)
lib/future: computations that are Exn can be replaced
A computation that is an exception morally holds no value hence can be replaced by an type-equivalent computation. This mechanism is used to edit broken proofs. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16808 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib/future.ml')
-rw-r--r--lib/future.ml9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/future.ml b/lib/future.ml
index 6001da30d7..c1fb176df6 100644
--- a/lib/future.ml
+++ b/lib/future.ml
@@ -47,6 +47,10 @@ let is_val x = match !x with
| Val _ -> true
| Exn _ | Closure _ | Delegated | Dropped -> false
+let is_exn x = match !x with
+ | Exn _ -> true
+ | Val _ | Closure _ | Delegated | Dropped -> false
+
let peek_val x = match !x with
| Val (v, _) -> Some v
| Exn _ | Closure _ | Delegated | Dropped -> None
@@ -103,6 +107,11 @@ let chain ?(id="none") ?(pure=false) c f = ref (match !c with
let create_here f = chain ~pure:false (from_here ()) f
+let replace x y =
+ match !x with
+ | Exn _ -> x := Closure (fun () -> force ~pure:false y)
+ | _ -> Errors.anomaly (Pp.str "Only Exn futures can be replaced")
+
let purify f x =
let state = !freeze () in
try