* 'concat_record_fields' concatenates a list of records fields into
* a record. The list must have at least one element.
*
+ * 'build_record' builds a record out of record fields.
+ *
* 'build_tuple_from_exprs' builds an arbitrary length tuple from
* a list of expressions of length >= 2.
*
- * Thanks to bluestorm on #ocaml for getting the last one working.
+ * Thanks to bluestorm on #ocaml for getting these working.
*)
let concat_str_items _loc items =
match items with
| rb :: rbs ->
List.fold_left (fun rbs rb -> <:rec_binding< $rbs$ ; $rb$ >>) rb rbs
+let build_record _loc rbs =
+ Ast.ExRec (_loc, rbs, Ast.ExNil _loc)
+
let build_tuple_from_exprs _loc exprs =
match exprs with
| [] | [_] -> assert false
let fieldsigs = fields @ fields_not_present in
let fsname = sprintf "fieldsig_%d" i in
let fieldsigs = concat_record_bindings _loc fieldsigs in
+ let fieldsigs = build_record _loc fieldsigs in
<:str_item<
- let $lid:fsname$ = { () with $fieldsigs$ }
+ let $lid:fsname$ = $fieldsigs$
>>
) parsers in