title: OCaml interface vs. signature?
body: <p>I'm a bit confused about interfaces vs. signatures in OCaml. 
  From what I've read, interfaces (the .mli files) are what govern what values can be used/called by the other programs. Signature files look like they're exactly the same, except that they name it, so that you can create different implementations of the interface.
  For example, if I want to create a module that is similar to a set in Java:</p>
  
  <p>I'd have something like this:</p>
  
  <p>the set.mli file:</p>
  
  <pre><code>type 'a set
    val is_empty : 'a set -&gt; bool
    val ....
    etc.
  </code></pre>
  
  <p>The signature file (setType.ml)</p>
  
  <pre><code>module type Set = sig
    type 'a set
  
    val is_empty : 'a set -&gt; bool 
    val ...
    etc.
  end
  </code></pre>
  
  <p>and then an implementation would be another .ml file, such as SpecialSet.ml, which includes a struct that defines all the values and what they do.</p>
  
  <pre><code>module SpecialSet : Set
  struct
   ...
  </code></pre>
  
  <p>I'm a bit confused as to what exactly the "signature" does, and what purpose it serves. Isn't it acting like a sort of interface? Why is both the .mli and .ml needed? The only difference in lines I see is that it names the module. </p>
  
  <p>Am I misunderstanding this, or is there something else going on here?</p>