automatically resolving open?

Kenichi Asai <[email protected]> Wed, 23 Apr 2025 23:10:38 +0900
Newsgroups gmane.comp.lang.caml.inria
Message-ID <[email protected]>
Would it be possible to transform an OCaml file to the one that does
not use open?  For example, if I have:

open List
let test = map (fun x -> x + 1) [1; 2; 3]

I want to obtain:

let test = List.map (fun x -> x + 1) [1; 2; 3]

where all the opened identifiers are prefixed with the opened module
names.

ocamlc -dtypedtree appears to produce a typed tree where all the
opened variable references are resolved.  Would it be possible to
transform this typed tree back to a source program?

-- 
Kenichi Asai