title: How Do I Use A Variable As The Formatting String With Sprintf?
body: <p>I feel like a total noob for having to ask this but it's got me stumped.</p>
  
  <p>I set a format string like this:</p>
  
  <pre><code>let fs = "This is my format test %s"
  </code></pre>
  
  <p>Then I attempt to use it like so:</p>
  
  <pre><code>let s = sprintf fs "testing"
  </code></pre>
  
  <p>When I do so I get this error:</p>
  
  <pre><code>//stdin(26,17): error FS0001: The type 'string' is not compatible with the type 'Printf.StringFormat&lt;('a -&gt; 'b)&gt;'
  </code></pre>
  
  <p>So I then tried this:</p>
  
  <pre><code>let s = sprintf (Printf.StringFormat fs) "test"
  </code></pre>
  
  <p>to which the REPL responded:</p>
  
  <pre><code>//stdin(28,18): error FS1124: Multiple types exist called 'StringFormat', taking different numbers of generic parameters. Provide a type instantiation to disambiguate the type resolution, e.g. 'StringFormat&lt;_&gt;'.
  </code></pre>
  
  <p>So I then tried this:</p>
  
  <pre><code>let s = sprintf (Printf.StringFormat&lt;string&gt; fs) "test" 
  </code></pre>
  
  <p>And I get this:</p>
  
  <pre><code>//stdin(29,18): error FS0001: The type ''a -&gt; 'b' does not match the type 'string'
  </code></pre>
  
  <p>Am I missing something painfully obvious? This is using F# 3.0 on the Mac from the Xamarin Studio F# Interactive Window.</p>