@@ -39,6 +39,7 @@ and ident_exn = ident_create "exn"
3939and ident_array = ident_create " array"
4040and ident_list = ident_create " list"
4141and ident_option = ident_create " option"
42+ and ident_result = ident_create " result"
4243
4344and ident_int64 = ident_create " int64"
4445and ident_lazy_t = ident_create " lazy_t"
@@ -80,6 +81,7 @@ and path_exn = Pident ident_exn
8081and path_array = Pident ident_array
8182and path_list = Pident ident_list
8283and path_option = Pident ident_option
84+ and path_result = Pident ident_result
8385
8486
8587and path_int64 = Pident ident_int64
@@ -102,7 +104,7 @@ and type_exn = newgenty (Tconstr(path_exn, [], ref Mnil))
102104and type_array t = newgenty (Tconstr (path_array, [t], ref Mnil ))
103105and type_list t = newgenty (Tconstr (path_list, [t], ref Mnil ))
104106and type_option t = newgenty (Tconstr (path_option, [t], ref Mnil ))
105-
107+ and type_result t1 t2 = newgenty ( Tconstr (path_result, [t1; t2], ref Mnil ))
106108
107109and type_int64 = newgenty (Tconstr (path_int64, [] , ref Mnil ))
108110and type_lazy_t t = newgenty (Tconstr (path_lazy_t, [t], ref Mnil ))
@@ -117,6 +119,8 @@ let ident_match_failure = ident_create_predef_exn "Match_failure"
117119
118120and ident_invalid_argument = ident_create_predef_exn " Invalid_argument"
119121and ident_failure = ident_create_predef_exn " Failure"
122+ and ident_ok = ident_create_predef_exn " Ok"
123+ and ident_error = ident_create_predef_exn " Error"
120124
121125and ident_js_error = ident_create_predef_exn " JsError"
122126and ident_not_found = ident_create_predef_exn " Not_found"
@@ -213,6 +217,15 @@ let common_initial_env add_type add_extension empty_env =
213217 type_arity = 1 ;
214218 type_kind = Type_variant ([cstr ident_none []; cstr ident_some [tvar]]);
215219 type_variance = [Variance. covariant]}
220+ and decl_result =
221+ let tvar1, tvar2 = newgenvar() , newgenvar() in
222+ {decl_abstr with
223+ type_params = [tvar1; tvar2];
224+ type_arity = 2 ;
225+ type_kind =
226+ Type_variant ([cstr ident_ok [tvar1];
227+ cstr ident_error [tvar2]]);
228+ type_variance = [Variance. covariant; Variance. covariant]}
216229 and decl_uncurried =
217230 let tvar1, tvar2 = newgenvar() , newgenvar() in
218231 {decl_abstr with
@@ -278,6 +291,7 @@ let common_initial_env add_type add_extension empty_env =
278291
279292 add_type ident_lazy_t decl_lazy_t (
280293 add_type ident_option decl_option (
294+ add_type ident_result decl_result (
281295 add_type ident_list decl_list (
282296 add_type ident_array decl_array (
283297 add_type ident_exn decl_exn (
@@ -291,7 +305,7 @@ let common_initial_env add_type add_extension empty_env =
291305 add_type ident_extension_constructor decl_abstr (
292306 add_type ident_floatarray decl_abstr (
293307 add_type ident_promise decl_promise (
294- empty_env)))))))))))))))))))))))))
308+ empty_env))))))))))))))))))))))))))
295309
296310let build_initial_env add_type add_exception empty_env =
297311 let common = common_initial_env add_type add_exception empty_env in
0 commit comments