aboutsummaryrefslogtreecommitdiff
path: root/lib/option.ml
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2014-03-01 18:26:26 +0100
committerPierre-Marie Pédrot2014-03-01 22:45:39 +0100
commit87b510e5b0f363724eae5db9f177f167a3586015 (patch)
tree204c7ad1e1ba38945ab58d74e28d8cf67201fe71 /lib/option.ml
parentbca756eaebf16b6145c65b53629219d2a0a8b1ba (diff)
Fixing pervasive comparisons
Diffstat (limited to 'lib/option.ml')
-rw-r--r--lib/option.ml6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/option.ml b/lib/option.ml
index 02adc69478..1ef45d232e 100644
--- a/lib/option.ml
+++ b/lib/option.ml
@@ -29,6 +29,12 @@ let equal f x y = match x, y with
| Some x, Some y -> f x y
| _, _ -> false
+let compare f x y = match x, y with
+| None, None -> 0
+| Some x, Some y -> f x y
+| None, Some _ -> -1
+| Some _, None -> 1
+
exception IsNone
(** [get x] returns [y] where [x] is [Some y]. It raises IsNone