title: Overloading one operator with different argument types in the same type definition?
body: <p>is it possible to have the same operator in a type definition work with different types on the right-hand side of the operator?</p>
  
  <p>Definition of the |== operator via name plugElts compiles fine, but using it later in module RemoverTest fails with <code>error FS0002: This function takes too many arguments, or is used in a context where a function is not expected</code> when function is supplied on the right-hand side.  </p>
  
  <pre><code>module SampleOperators =
  
      let inline (|==) (x: ^URel) (wires: ^Wires) =
          (^URel: (static member plugElts: ^URel * ^Wires -&gt; 'R) (x, wires))
  
  module Remover =
  
      open SampleOperators
  
      type RemGroup&lt;'G&gt; = RemGroupPass | RemGroupAll | RemGroupExcept of 'G | RemGroupElts of 'G
      type RemMap&lt;'K,'P when 'K: comparison&gt; =
          RemGroup&lt;Map&lt;'K,'P&gt;&gt;
      type RemFun&lt;'K,'P when 'K: comparison&gt; =
          'K * 'P -&gt; bool
      type Rem&lt;'K,'MapVal,'FunVal when 'K:comparison&gt; =
          | Map_ of RemMap&lt;'K,'MapVal&gt;
          | Fun_ of RemFun&lt;'K,'FunVal&gt;
  
      type X&lt;'K,'P when 'K:comparison&gt; =
          { id: 'K
            vv: Rem&lt;'K,'P,'P&gt; }
          static member inline plugElts (x:X&lt;_,_&gt;, ws:('K * 'P) seq) =
              {x with vv = Map_ (RemGroupElts (Map.ofSeq ws))}
  
          static member inline plugElts (x:X&lt;_,_&gt;, i:int) =
              {x with vv = Map_ (RemGroupElts (Map.ofSeq [i,i]))}
  
          static member inline plugElts (x:X&lt;_,_&gt;, fn:('K * 'P -&gt; bool)) =
              {x with vv = Fun_ fn}
  
  
  module RemoverTest =
  
      open Remover
      open SampleOperators
  
      let xxx1 () =
          {id = 1; vv = Map_ RemGroupPass} |== [1,1]   // compiles ok
  
      let xxx2 () =
          {id = 1; vv = Map_ RemGroupPass} |== 1       // compiles ok
  
      let xxx3 () =
          ({id = 1; vv = Map_ RemGroupPass}:X&lt;_,_&gt;) |== (fun _ -&gt; bool)  // can't compile
  </code></pre>
  
  <p>Are there ways to make this work without wrapping the right-hand side in discriminated union?</p>
  
  <p>Thanks,
    Karol</p>
  
  <p>edit: added overload for right-hand side with int type which works fine</p>