F# operator not resolving properly

Viewed 76
let inline (=~) a b = abs (single a - single b) <= 0.001f

type Vector =
    { x : single; y : single; z : single }

    static member (=~) (v1, v2) = (v1.x =~ v2.x) && (v1.y =~ v2.y) && (v1.z =~ v2.z)

let v1, v2 =
    { x = 0.1f; y = single Math.PI; z = 0.f },
    { x = 0.1f; y = 3.14159f; z = 0.0001f }

v1 =~ v2

Compiler complains: The type 'Vector' does not support a conversion to the type 'single'

I don't get it. Clearly, the type-specific operator doesn't take precedence over the generic operator, foiling my intuition. What's the trick to making this work?

2 Answers
Related