Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[enhance] option: add merge in opa and modify ml

  • Loading branch information...
commit 675bf6703e79dc30a2c14842cc83682ccea70925 1 parent c914d2a
Damien Graux authored
Showing with 7 additions and 2 deletions.
  1. +1 −2  libbase/option.ml
  2. +6 −0 stdlib/core/option.opa
View
3  libbase/option.ml
@@ -116,8 +116,7 @@ let make_compare cmp o1 o2 =
let merge conflict o1 o2 =
match o1, o2 with
- | None, None -> None
- | Some _, None -> o1
+ | _, None -> o1
| None, Some _ -> o2
| Some x1, Some x2 -> Some (conflict x1 x2)
View
6 stdlib/core/option.opa
@@ -178,6 +178,12 @@ Option = {{
make_order(using: order('a, 'b)): order(option('a), 'b) =
Order.make(ordering(using, _, _))
+ merge( f:('a,'a -> 'a), x:option('a), y:option('a) ): option('a) =
+ match (x, y) with
+ | (_, {none}) -> x
+ | ({none}, {some=_}) -> y
+ | ({some=a}, {some=b}) -> {some=f(a,b)}
+
}}
Please sign in to comment.
Something went wrong with that request. Please try again.