title: Can I rewrite this code to avoid the F# error
body: <p>I have the following code in F#</p>
  
  <p>live version at <a href="https://repl.it/repls/CarefulGiganticExtraction" rel="nofollow noreferrer">https://repl.it/repls/CarefulGiganticExtraction</a></p>
  
  <pre><code>let inline tryParse text = 
      let mutable r = Unchecked.defaultof&lt;_&gt;
      (^a : (static member TryParse: string * ^a byref -&gt; bool) (text, &amp;r)), r 
  
  let inline tryParseWithDefault (defaultVal:'a) text =
      match tryParse text with 
      | true, v -&gt; v
      | _ -&gt; defaultVal
  
  type TextBox(text:string) =
    member this.Text = text
  
  type View() =
     member this.Name = "View"
  
  type State = { count: int }
  
  
  module Binder =
      let inline oneWay defaultValue update dispatch (sender:obj) _ =
          let value = 
              match sender with 
              | :? TextBox as textBox -&gt; tryParseWithDefault defaultValue (textBox.Text) 
              | _ -&gt; defaultValue
          dispatch (fun state -&gt; update state value ) 
  
  let view (state: State) (dispatch): View =
      // Create a partially applied oneWay binding function
      // This fails to compile due to 
      // "The type of a first class function cannot contain byrefs"
      let inline oneWay defaultValue update = 
          Binder.oneWay defaultValue update dispatch 
  
      // Return the mock view
      View()   
  
  </code></pre>
  
  <p>This is a cut down mock of some real code I'm trying to prototype to work with <a href="https://github.com/JaggerJo/Avalonia.FuncUI" rel="nofollow noreferrer">FuncUI</a> an Elmish dialect for Avalonia.</p>
  
  <p>The problem is that I get the compile error when I try to create the partial application of Binder.oneWay</p>
  
  <pre><code>let inline oneWay defaultValue update = 
      Binder.oneWay defaultValue update dispatch
  </code></pre>
  
  <blockquote>
    <p>error FS0425: The type of a first-class function cannot contain byrefs</p>
  </blockquote>
  
  <p>Is it possible to create a partial application of the Binder.oneWay function at the top of the view function or have I coded myself into a corner?</p>
  
  <p>Again the live version is at</p>
  
  <p><a href="https://repl.it/repls/CarefulGiganticExtraction" rel="nofollow noreferrer">https://repl.it/repls/CarefulGiganticExtraction</a></p>