Commit 46aedafd authored by POTTIER Francois's avatar POTTIER Francois

A more general version of [is_local].

parent 882301bf
......@@ -646,7 +646,8 @@ let rec visit_type (env_in_scope : bool) (ty : core_type) : expression =
applied to the visitor functions associated with SOME of the [tys]. *)
let tys =
match is_local X.decls tycon with
| Some formals ->
| Some decl ->
let formals = decl_params decl in
(* [tycon] is a local type constructor, whose formal type parameters
are [formals]. Among these formal type parameters, some should be
treated in a monomorphic manner, and some should be treated in a
......
......@@ -114,20 +114,22 @@ let decl_params (decl : type_declaration) : tyvars =
type_params_to_tyvars decl.ptype_params
(* [is_local decls tycon] tests whether the type constructor [tycon] is
declared by the type declarations [decls]. If so, it returns the list
of its formal type parameters. *)
declared by the type declarations [decls]. If so, it returns the
corresponding declaration. *)
let rec is_local (decls : type_declaration list) (tycon : tycon) : tyvars option =
let rec is_local (decls : type_declaration list) (tycon : tycon)
: type_declaration option =
match decls with
| [] ->
None
| decl :: decls ->
if decl.ptype_name.txt = tycon then
Some (decl_params decl)
Some decl
else
is_local decls tycon
let is_local (decls : type_declaration list) (tycon : Longident.t) : tyvars option =
let is_local (decls : type_declaration list) (tycon : Longident.t)
: type_declaration option =
match tycon with
| Lident tycon ->
is_local decls tycon
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment