Suppose you want to write a function "gen" that generates a function with a signature given by a list of types:
let gen (sig:Type list) = ....
let sig = [ typeof<int>; typeof<int[]>; typeof<float> ]
let func = gen sig
then func is of type: int -> int[] -> float -> unit
I thought of two possible solutions:
a) Using Reflect Emit, but I don't know if this way we can make the IntelliSense working? Reflect Emit seems to create new .net code, which the IntelliSense might not see, so it might not verify the code at compile time.
b) Using type provider, but I fear is too heavy and may not be practical.
c) Using generics, like the gen<'T1> (sig:Type list) : 'T2 -> unit
, this may need recursive calls, but I didn't figured out how to do this.
I would prefer method c), because it is lightweight, and can be checked at compile time. Or is there an alternative approach?