Skip to content
Browse files

split ors in PaOlbi for benefit of alist

  • Loading branch information...
1 parent 68f9743 commit b4875243777c299a9a8a4dd1dc3d2432bd23c771 Jake Donham committed
Showing with 15 additions and 7 deletions.
  1. +14 −7 applications/alist/alist_tests.ml
  2. +1 −0 patterns.ml
View
21 applications/alist/alist_tests.ml
@@ -13,14 +13,21 @@ let test thunk =
module Tests (S : sig end) =
struct
- let foo = ["foo", 5; "bar", 6; "baz", 7] in
+ let _ =
+ test
+ (lazy
+ (assert
+ (match ["foo", 5; "bar", 6; "baz", 7] with
+ | alist [ "bar", x; "foo", y ] ->
+ x - y = 1)))
- test
- (lazy
- (assert
- (match foo with
- | alist [ "bar", x; "foo", y ] ->
- x - y = 1)))
+ let _ =
+ test
+ (lazy
+ (assert
+ (match ["foo", [ "bar", 6 ]] with
+ | alist [ "foo", (alist [ "bar", x ] | alist [ "baz", x ]) ] ->
+ x = 6)))
end
let _ =
View
1 patterns.ml
@@ -44,6 +44,7 @@ struct
| <:patt< $p$; $q$ >> -> split p (fun p -> split q (fun q -> return (<:patt< $p$; $q$ >>)))
| <:patt< $l$ = $p$ >> -> split p (fun p -> return (<:patt< $l$ = $p$ >>))
| <:patt< ($p$ : $t$) >> -> split p (fun p -> return (<:patt< ($p$ : $t$) >>))
+ | Ast.PaOlbi (loc, s, p, e) -> split p (fun p -> return (Ast.PaOlbi (loc, s, p, e))) (* hack for alist *)
(* nothing else (except labeled patterns) has sub-patterns *)
| pat -> return pat in
split p (fun p -> [p])

0 comments on commit b487524

Please sign in to comment.
Something went wrong with that request. Please try again.