From 6dc2b0f0906adc5d6f8f2f48404cf21d3595c957 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 21 Dec 2023 23:02:51 +0100 Subject: Improve the pure micro passes --- compiler/PureUtils.ml | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'compiler/PureUtils.ml') diff --git a/compiler/PureUtils.ml b/compiler/PureUtils.ml index 78d0b120..cc439e64 100644 --- a/compiler/PureUtils.ml +++ b/compiler/PureUtils.ml @@ -739,3 +739,16 @@ let rec destruct_lambdas (e : texpression) : typed_pattern list * texpression = let pats, e = destruct_lambdas e in (pat :: pats, e) | _ -> ([], e) + +let opt_dest_tuple_texpression (e : texpression) : texpression list option = + let app, args = destruct_apps e in + match app.e with + | Qualif { id = AdtCons { adt_id = TTuple; variant_id = None }; generics = _ } + -> + Some args + | _ -> None + +let opt_dest_struct_pattern (pat : typed_pattern) : typed_pattern list option = + match pat.value with + | PatAdt { variant_id = None; field_values } -> Some field_values + | _ -> None -- cgit v1.2.3