diff options
Diffstat (limited to 'compiler/PureUtils.ml')
-rw-r--r-- | compiler/PureUtils.ml | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/PureUtils.ml b/compiler/PureUtils.ml index 5a024d9e..728a4fe6 100644 --- a/compiler/PureUtils.ml +++ b/compiler/PureUtils.ml @@ -206,6 +206,15 @@ let mk_arrows (inputs : ty list) (output : ty) = in aux inputs +(** Destruct an expression into a list of nested lets *) +let rec destruct_lets (e : texpression) : + (bool * typed_pattern * texpression) list * texpression = + match e.e with + | Let (monadic, lv, re, next_e) -> + let lets, last_e = destruct_lets next_e in + ((monadic, lv, re) :: lets, last_e) + | _ -> ([], e) + (** Destruct an [App] expression into an expression and a list of arguments. We simply destruct the expression as long as it is of the form [App (f, x)]. |