diff options
author | Son Ho | 2022-11-14 09:27:24 +0100 |
---|---|---|
committer | Son HO | 2022-11-14 14:21:04 +0100 |
commit | 1af63cade04325eb32a62ca23125eea75810822f (patch) | |
tree | 3aa1a74d5f59a8c197154ea48e7cf0b8da3f0f68 /compiler/PureUtils.ml | |
parent | 3eba613a9ff9d5c265fbe2676f6bd324728d9ca4 (diff) |
Improve the formatting of the generated code
Diffstat (limited to '')
-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)]. |