I need to call a function that takes System.Array []
as one parameter in F#. (The function is in a library).
I need to pass an argument of type float [] [] []
but the compiler refuses to compile. To replicate the problem, I wrote the following code
let x : float [] [] = Array.init 2 (fun x -> Array.zeroCreate 3)
x :> System.Array;; // This is OK
val x : float [] [] = [|[|0.0; 0.0; 0.0|]; [|0.0; 0.0; 0.0|]|]
> x :> System.Array [];; //Error
x :> System.Array [];;
^^^^^^^^^^^^^^^^^^^^
stdin(14,1): warning FS0059: The type 'System.Array []' does not have any proper subtypes and need not be used as the target of a static coercion
x :> System.Array [];;
^^^^^^^^^^^^^^^^^^^^
stdin(14,1): error FS0193: Type constraint mismatch. The type
float [] []
is not compatible with type
System.Array []
The type 'System.Array' does not match the type 'float []'
How can I solve this problem?
Thanks in advance.