(this scenario doesnt seem to be answered by a previous thread, or at least not in way thats obvious to me, the crucial difference is the recursive requirement for higher order types)
(I've rewritten this question to give something that works...but is painful...rather than vague aspirations around constraints)
I have some code a bit like this (but many many more types)...
type TypeOfOperator =
static member typeOf(i : TypeOf<int>) = 1
static member typeOf(i : TypeOf<string>) = 2
static member typeOf(i : TypeOf<seq<int>>) = 3 + TypeOfOperator.typeOf(TypeOf<int>())
static member typeOf(i : TypeOf<seq<string>>) = 3 + TypeOfOperator.typeOf(TypeOf<string>())
static member typeOf(i : TypeOf<option<int>>) = 4 + TypeOfOperator.typeOf(TypeOf<int>())
static member typeOf(i : TypeOf<option<string>>) = 4 + TypeOfOperator.typeOf(TypeOf<string>())
let x = TypeOfOperator.typeOf(TypeOf<int>())
let y = TypeOfOperator.typeOf(TypeOf<string>())
let z = TypeOfOperator.typeOf(TypeOf<seq<int>>())
let a = TypeOfOperator.typeOf(TypeOf<seq<string>>())
this code works!...and for atom types (like "int"), this construction is pretty inherent, BUT the formualtion of higher order types (e.g. seq< int >) is formulaic...i.e. a constant "+" some recursive invocation on the parameter type....yet this doesnt seem to be capturable in F#, I have to labouriously manually implement the code.
Ideally the method for option< > would/should be imlement once, something like....
static member typeOf<'a>(i : TypeOf<option<'a>>) = 4 + TypeOfOperator.typeOf(TypeOf<'a>())
i.e. written once...but this clearly doesnt compile.
Is there a way in f# to implement the above method/function?