Commit 6bfd690b authored by POTTIER Francois's avatar POTTIER Francois

Added [CodeBits.eletand].

parent 66354449
......@@ -114,6 +114,21 @@ let blet (bindings, body) =
let mlet formals actuals body =
blet (List.combine formals actuals, body)
(* Simulating a [let/and] construct using tuples. *)
let eletand (bindings, body) =
match bindings with
| [] ->
(* special case: zero bindings *)
body
| [ _ ] ->
(* special case: one binding *)
ELet (bindings, body)
| _ :: _ :: _ ->
(* general case: at least two bindings *)
let pats, exprs = List.split bindings in
ELet ([ PTuple pats, ETuple exprs ], body)
(* [eraisenotfound] is an expression that raises [Not_found]. *)
let eraisenotfound =
......@@ -225,4 +240,3 @@ let with_types wk name tys =
List.fold_left (fun mt (params, name, ty) ->
MTWithType (mt, params, name, wk, ty)
) (MTNamedModuleType name) tys
......@@ -43,6 +43,10 @@ val pat2var: pattern -> string
val blet: (pattern * expr) list * expr -> expr
val mlet: pattern list -> expr list -> expr -> expr
(* Simulating a [let/and] construct. *)
val eletand: (pattern * expr) list * expr -> expr
(* [eraisenotfound] is an expression that raises [Not_found]. *)
val eraisenotfound: expr
......@@ -89,4 +93,3 @@ val interface_to_structure: interface -> structure
(* Constructing a named module type together with a list of "with type"
constraints. *)
val with_types: IL.with_kind -> string -> (string list * string * IL.typ) list -> IL.module_type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment