let ident_of_patt =
let error () =
invalid_arg
"ident_of_patt: this pattern is not an identifier" in
let rec self =
function
| Ast.PaApp (_loc, p1, p2) ->
Ast.IdApp (_loc, (self p1), (self p2))
| Ast.PaId (_, (Ast.IdLid (_, _))) -> error ()
| Ast.PaId (_, i) ->
if is_module_longident i then i else error ()
| _ -> error ()
in function | Ast.PaId (_, i) -> i | p -> self p