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 t
I'm not sure what your goal is.
If what you want is to read properties of a generic record see TheInnerLight's working example.
If, instead, you want to write a function that clones many types of records, then you should change your design. You can follow the approach suggested by Tomas.
In addition to all that, here's another alternative: use a nested generic record.
type Test<'a> = {Bar : string; Rest : 'a}
type A = {PropA : string}
type B = {PropB : int}
let a = {Bar = "bar"; Rest = {PropA = "propA" }}
let foo a = {a with Bar = "foo " + a.Bar}
let foobar = foo {Bar = "bar"; Rest = {PropA = "propA"}}
// val foobar : Test = {Bar = "foo bar"; Rest = {PropA = "propA";};}
let foobar' = foo {Bar = "bar"; Rest = {PropB = 0}}
// val foobar' : Test = {Bar = "foo bar"; Rest = {PropB = 0;};}
As a final note, with this design, you can move to Lenses as FyodorSoikin initially suggested.