Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Hongbo Zhang committed Jun 27, 2016
1 parent a1aa145 commit ba8ed35
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions jscomp/syntax/ast_comb.ml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,22 @@ let tuple_type_pair ?loc kind arity =



let obj_type_pair ?loc arity =
let obj = Typ.var ?loc "obj" in
let prefix = "a" in
if arity = 0 then
let ty = Typ.var ?loc ( prefix ^ "0") in
(Typ.arrow "" ?loc
obj
ty ,
(obj, ty))
else
let tys = Ext_list.init (arity + 1) (fun i ->
Typ.var ?loc (prefix ^ string_of_int i)
) in
(Typ.arrow "" ?loc obj
(Ext_list.reduce_from_right (fun x y -> Typ.arrow "" ?loc x y) tys),
(obj, Typ.tuple ?loc tys))



5 changes: 5 additions & 0 deletions jscomp/syntax/ast_comb.mli
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,8 @@ val tuple_type_pair :
[`Make | `Run ] ->
int ->
Parsetree.core_type * Parsetree.core_type


val obj_type_pair :
?loc:Ast_helper.loc ->
int -> Parsetree.core_type * (Parsetree.core_type * Parsetree.core_type)

0 comments on commit ba8ed35

Please sign in to comment.