summaryrefslogtreecommitdiff
path: root/src/pattern_completeness.ml
diff options
context:
space:
mode:
authorJon French2018-05-02 12:00:07 +0100
committerJon French2018-05-02 12:00:07 +0100
commit0c062d51d850c77d01fc3e78a73778e6f5aa7a59 (patch)
tree8c78f252430096dd46441de71a54dd10d1ba7276 /src/pattern_completeness.ml
parent274b7517f07076be19eedc1bdade6db2c649a8bc (diff)
refactor string append pattern ast to be based on lists rather than pairs
Diffstat (limited to 'src/pattern_completeness.ml')
-rw-r--r--src/pattern_completeness.ml11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/pattern_completeness.ml b/src/pattern_completeness.ml
index 3797354c..2372ea82 100644
--- a/src/pattern_completeness.ml
+++ b/src/pattern_completeness.ml
@@ -68,7 +68,7 @@ type gpat =
| GP_cons of gpat * gpat
| GP_app of (gpat Bindings.t)
| GP_record of (gpat Bindings.t)
- | GP_string_append of gpat * gpat
+ | GP_string_append of gpat list
let rec string_of_gpat = function
| GP_lit lit -> string_of_lit lit
@@ -81,7 +81,7 @@ let rec string_of_gpat = function
| GP_app app ->
Util.string_of_list "|" (fun (id, gpat) -> string_of_id id ^ string_of_gpat gpat) (Bindings.bindings app)
| GP_record _ -> "GP RECORD"
- | GP_string_append (gpat1, gpat2) -> string_of_gpat gpat1 ^ " ^^" ^ string_of_gpat gpat2
+ | GP_string_append gpats -> Util.string_of_list " ^^ " string_of_gpat gpats
let is_wild = function
| GP_wild -> true
@@ -119,10 +119,9 @@ let rec generalize ctx (P_aux (p_aux, _) as pat) =
let ghd_pat = generalize ctx hd_pat in
let gtl_pat = generalize ctx tl_pat in
if is_wild ghd_pat && is_wild gtl_pat then GP_wild else GP_cons (ghd_pat, gtl_pat)
- | P_string_append (pat1, pat2) ->
- let gpat1 = generalize ctx pat1 in
- let gpat2 = generalize ctx pat2 in
- if is_wild gpat1 && is_wild gpat2 then GP_wild else GP_string_append (gpat1, gpat2)
+ | P_string_append pats ->
+ let gpats = List.map (generalize ctx) pats in
+ if List.for_all is_wild gpats then GP_wild else GP_string_append gpats
| P_app (f, pats) ->
let gpats = List.map (generalize ctx) pats in
if List.for_all is_wild gpats then