let ident_of_ctyp =
let error () =
invalid_arg "ident_of_ctyp: this type is not an identifier" in
let rec self =
function
| Ast.TyApp (_loc, t1, t2) ->
Ast.IdApp (_loc, (self t1), (self t2))
| Ast.TyId (_, (Ast.IdLid (_, _))) -> error ()
| Ast.TyId (_, i) ->
if is_module_longident i then i else error ()
| _ -> error ()
in function | Ast.TyId (_, i) -> i | t -> self t