title: F# Common infix operators (fmap, applicative, bind, etc) for multiple types
body: <p>What I would like do is use infix fmap (which I have defined as &lt;^>) to work for multiple types such as Option and Either (custom type).</p>
  
  <p>Given:</p>
  
  <pre><code>   type Either&lt;'a, 'b&gt; = Left of 'a | Right of 'b 
  </code></pre>
  
  <p>In code I would like to be able to do:</p>
  
  <pre><code>   let fO (a : int option) = None
     let fE (a : Either&lt;string,int&gt;) = Left "dummy"
  
     let mO = Some 1
     let mE = Right 1
  
     let testO = f0 &lt;^&gt; m0
     let testE = fE &lt;^&gt; mE
  </code></pre>
  
  <p>Where (&lt;^>) for each:</p>
  
  <pre><code>    let (&lt;^&gt;) f m = match m with | Some a -&gt; Some &lt;| f a | None -&gt; None
      let (&lt;^&gt;) f m = match m with | Right a -&gt; Right &lt;| f a | Left a -&gt; Left a
  </code></pre>
  
  <p>To get the Option &lt;^> to work I have extended the module :</p>
  
  <pre><code>    namespace Microsoft.FSharp.Core
      [&lt;AutoOpen&gt;]
      module Option =
      let (&lt;^&gt;) f m = match m with | Some a -&gt; Some &lt;| f a | None -&gt; None
  
      [&lt;assembly:AutoOpen("Microsoft.FSharp.Core")&gt;]
      do ()
  </code></pre>
  
  <p>And for Either:</p>
  
  <pre><code>    type Either&lt;'a, 'b&gt; = Left of 'a | Right of 'b with
         static member (&lt;^&gt;) (f,m) = match m with | Right a -&gt; Right &lt;| f a | Left a -&gt; Left a
  </code></pre>
  
  <p>This almost works, however only one can be used at a time.
  An Either module can be also appended to FSharp.Core, but then equally you can only have one or the other.</p>
  
  <p>I'm aware this can be completed with 2 custom types, say Either and Maybe (Haskell option), I would however like to stick with Option.</p>
  
  <p>Any and all suggestions welcome.</p>