title: OCaml how to fix module name collisions
body: <p>When making a toplevel, module names are not allowed to conflict with internal compiler libs.</p>
  
  <p>What are some strategies for fixing this sorts of module name collisions?</p>
  
  <p>Ideally, is it possible to pass some argument to <code>ocamlc</code> to instruct it to "mangle" the names of all the modules to use a custom prefix like <code>MyProject_</code>? (from the perspective of the OCaml ABI, not literally changing source files)</p>
  
  <p>Full example below:</p>
  
  <p><code>Sqrt.ml</code> contains</p>
  
  <pre><code>let sqrt x = x ** 0.5
  </code></pre>
  
  <p><code>Sqrt.mli</code> contains</p>
  
  <pre><code>val sqrt : float -&gt; float
  </code></pre>
  
  <p><code>mktop</code> contains</p>
  
  <pre><code>#!/bin/bash
  
  ocamlc -c Sqrt.mli -o Sqrt.cmi 
  ocamlc -c Sqrt.ml  -o Sqrt.cmo
  
  ocamlmktop -o sqrt_toplevel Sqrt.cmo
  </code></pre>
  
  <p>And I can produce a toplevel containing the function I want.</p>
  
  <pre><code>% ./sqrt_toplevel
          OCaml version 4.04.0
  
  # Sqrt.sqrt 4.5;;
  - : float = 2.12132034355964239
  </code></pre>
  
  <p>If I rename the <code>Sqrt</code> module to <code>Parse</code> by changing the file names, the name conflicts with an internal library and the toplevel fails to link.</p>
  
  <p><code>mktop</code> is now</p>
  
  <pre><code>#!/bin/bash
  
  ocamlc -c Parse.mli -o Parse.cmi 
  ocamlc -c Parse.ml  -o Parse.cmo
  
  ocamlmktop -o parse_toplevel Parse.cmo
  </code></pre>
  
  <p>with the other files simply renamed to <code>Parse.ml</code> and <code>Parse.mli</code>.</p>
  
  <p>If I do this, I get a naming conflict with a compiler lib.</p>
  
  <pre><code>% ./mktop |&amp; sed -e s:"$HOME":~:
  File "Parse.cmo", line 1:
  Warning 31: files Parse.cmo and ~/.opam/4.04.0/lib/ocaml/compiler-libs/ocamlcommon.cma(Parse) both define a module named Parse
  File "_none_", line 1:
  Error: Some fatal warnings were triggered (1 occurrences)
  Exit 2
  </code></pre>