diff options
Diffstat (limited to 'interp')
-rw-r--r-- | interp/genarg.ml | 2 | ||||
-rw-r--r-- | interp/genarg.mli | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/interp/genarg.ml b/interp/genarg.ml index eb5287b32..f9b5bee0a 100644 --- a/interp/genarg.ml +++ b/interp/genarg.ml @@ -197,6 +197,8 @@ let app_pair f1 f2 = function (u, Obj.repr (o1,o2)) | _ -> failwith "Genarg: not a pair" +let has_type (t, v) u = argument_type_eq t u + let unquote x = x type an_arg_of_this_type = Obj.t diff --git a/interp/genarg.mli b/interp/genarg.mli index 7f9d39907..4f5dea7ec 100644 --- a/interp/genarg.mli +++ b/interp/genarg.mli @@ -161,6 +161,10 @@ val out_gen : ('a, 'co) abstract_argument_type -> 'co generic_argument -> 'a (** [out_gen t x] recovers an argument of type [t] from a generic argument. It fails if [x] has not the right dynamic type. *) +val has_type : 'co generic_argument -> ('a, 'co) abstract_argument_type -> bool +(** [has_type v t] tells whether [v] has type [t]. If true, it ensures that + [out_gen t v] will not raise a dynamic type exception. *) + (** {6 Manipulation of generic arguments} Those functions fail if they are applied to an argument which has not the right |