I am trying to build a generic function to manipulate a record my code looks like:
type Status = Active | Inactive
type IStatus =
abstract member Status: Status
type User =
{
Username : string;
Status : Status
}
interface IStatus with
member x.Status = x.Status
let ChangeStatus<'T when 'T :> IStatus> newStatus (t:'T) =
{t with Status = newStatus}
Now I get the following error:
expression was expected to have type
'T
but here has type
User
Obviously I just want to create a type constraint for Records which implement IStatus. Am I thinking too OO? Or is there merit to this approach and how do I create this ChangeStatus
function?
Thank you for reading.