F# type constraint for record type with specific property
<p>I'm trying to create a generic function which requires of its type argument that it is a record type, and that it has a specific property. Here's a sample that generates the relevant compiler error:</p>

<pre><code>let foo&lt;'a&gt; (a : 'a) =
    a' = { a with bar = "baz" }
    a'
</code></pre>

<p>Compiling this I get an error stating <code>The record label bar is not defined</code>.</p>

<p>I tried adding the following type constraint:</p>

<pre><code>let foo&lt;'a when 'a : (member Id : string)&gt; =
    // ...
</code></pre>

<p>but that didn't compile either, complaining that <code>This code is not sufficiently generic. The type variable  ^a when  ^a : (member get_Int :  ^a -&gt; string) could not be generalized because it would escape its scope.</code></p>

<p>Is there a way to specify a type constraint that would let me do this properly?</p>