Commits

Dmitry Grebeniuk  committed 0fe4a9a

get_res

  • Participants
  • Parent commits 7736806

Comments (0)

Files changed (2)

     )
     (Obj.obj x_val_repr)
 ;
+
+
+type res 'a 'b = [= `Ok of 'a | `Error of 'b ]
+;
+
+
+value get_res ty var =
+  try
+    `Ok (get ty var)
+  with
+  [ Type_error ((_val, _used) as types) -> `Error types ]
+;
 
 WARNING!  It's not tested yet!
 
-Author: Dmitry Grebeniuk - gdsfh1 \@ gmail dot com
+Author: Dmitry Grebeniuk - gdsfh1 at gmail dot com
 *)
 
 (** Exception [Type_error (value_type, used_with_type)] is
 *)
 value get : ty 'a -> var -> 'a
 ;
+
+type res 'a 'b = [= `Ok of 'a | `Error of 'b ]
+;
+
+(** [get_res ty var] returns either [`Ok val] with value of
+    [var], or [`Error (value_type, used_with_type)] on type error.
+*)
+value get_res : ty 'a -> var -> res 'a (string * string)
+;