Commit 1829433a authored by POTTIER Francois's avatar POTTIER Francois

Add [Option.equal] and [Option.hash].

parent 3d0a97f6
......@@ -37,3 +37,19 @@ let project = function
| None ->
(* Presumably, an error message has already been printed. *)
exit 1
let equal equal o1 o2 =
match o1, o2 with
| None, None ->
true
| Some x1, Some x2 ->
equal x1 x2
| None, Some _
| Some _, None ->
false
let hash hash = function
| Some x ->
hash x
| None ->
Hashtbl.hash None
......@@ -15,3 +15,5 @@ val map: ('a -> 'b) -> 'a option -> 'b option
val iter: ('a -> unit) -> 'a option -> unit
val fold: ('a -> 'b -> 'b) -> 'a option -> 'b -> 'b
val project: 'a option -> 'a (* careful: calls [exit 1] in case of failure *)
val equal: ('a -> 'b -> bool) -> 'a option -> 'b option -> bool
val hash: ('a -> int) -> 'a option -> int
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment