Say I have a record type…
type Message<^a ...> =
{ id: Guid
causation: Guid
correlation: Guid
name: string
body: ^a }
I believe I need to use some duck typing to constrain the generic to implement OfJson and ToJson but I am struggling with the syntax.
Right now, I am using…
type Message< ^a when ^a : (static member OfJson: JsonValue -> ^a ParseResult)
and ^a : (static member ToJson : ^a -> JsonValue)>
but when I define Message.JsonObjCode as
with
static member JsonObjCodec = ...
I get an error ‘The code is not sufficiently generic. The type variable ^a (…) could not be generalized because it would escape its scope.’
Hmm, what am I missing?