I attempt the following:
let c x = System.Numerics.Complex(x, 0.0)
let sum = [c 1.0; c 2.0] |> List.sum
But I get this error:
The type 'System.Numerics.Complex' does not support the operator 'get_Zero'
I read the rules on type extensions, from https://msdn.microsoft.com/en-us/library/dd233211.aspx, and try to do the following:
module ComplexExtension =
let c x = System.Numerics.Complex(x, 0.0)
type System.Numerics.Complex with
// I also tried a bunch of other ways of writing these
// as static or instance members, but nothing worked
static member Zero = c 0.0
static member One = c 1.0
open ComplexExtension
let sum = [c 1.0; c 2.0] |> List.sum
I still get that error.
Is it possible to extend a type with the get_Zero operator? Or do I have to create my own wrapper type around System.Numerics.Complex
and override all the operators if I want it to do the other things that complex numbers do?