title: Why the compiler always wants this type once (=) is overloaded?
body: <p>I have a problem that I didn't understand since three days, since I don't understand, I can't solve it.</p>
  
  <p>I have code like this:</p>
  
  <pre><code>module SpotLocation = struct
  type t = {
      uuid : string option;
      netElement : string;
      coordIntrinsic : float;
  }
  end
  
  
  module Segment = struct
      type t ={
          netElement : string;
          coordFrom : SpotLocation.t;
          coordTo : SpotLocation.t;
      }
  
  
      let isEqual segA segB = segA.coordFrom = segB.coordFrom &amp;&amp; segA.coordTo = segB.coordTo
  
      let (=) = isEqual (* &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; Here is the problem *)
  
      let isIn seg loc = (seg.netElement = loc.netElement)
  
  end
  </code></pre>
  
  <p>The problem comes from (=) that I have overloaded.</p>
  
  <p>Once I have it, the compiler insists have the following reaction:</p>
  
  <pre><code>Error: This expression has type string but an expression was expected of type t
  </code></pre>
  
  <p>I have tried to declare the signature of (=) but it doesn't work.</p>
  
  <p>For example, this gives the same thing:</p>
  
  <pre><code>module Segment = struct
  type t ={
      netElement : string;
      coordFrom : SpotLocation.t;
      coordTo : SpotLocation.t;
  }
  
  
  let isEqual segA segB = segA.coordFrom = segB.coordFrom &amp;&amp; segA.coordTo = segB.coordTo
  
  let ((=) : t -&gt; t -&gt; bool) = isEqual (* &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; Here is the problem *)
  
  let isIn (seg : t) (loc : SpotLocation.t) =
  let open SpotLocation in
  seg.netElement = loc.netElement
  
  end
  </code></pre>
  
  <p>If I move the (=) after isIn, it works, but once I start to add some more logic it gives the same error. So I don't know what happens.</p>
  
  <p>Could anyone explain this to me? Thank you!</p>