Let’s say I have a bunch of vector types (a la XNA) and some of them have static member Cross:
type Vector3 =
...
static member Cross (a : Vector3, b : Vector3) = new Vector3(...)
I can define the cross function and it compiles:
let inline cross (x : ^T) (y : ^T) = (^T : (static member Cross : (^T * ^T) -> ^T) ((x,y)))
Unfortunately I’m not able to use it and have following error:
let res = cross a b
^
The member or object constructor Cross
takes 2 argument(s) but is here given
1. The required signature is static member Vector3.Cross :
a:Vector3 * b:Vector3 ->
Vector3
Is it even possible at all? Thanks for helping!
You’ve over-parenthesized your static member signature. Try this instead:
Given your definition, F# was looking for a member
Crosswhich takes a single argument of tuple type.