通用类型'T如何限制在这个Don Syme的代码上?

nic*_*las 4 generics f# constraints

let compareOn f x (yobj: obj) =
     match yobj with
     | :? 'T as y -> compare (f x) (f y)
     | _ -> invalidArg "yobj" "cannot compare values of different types"
Run Code Online (Sandbox Code Playgroud)

我不知道上面的'T与x的类型有什么关系.为什么x的类型不是'a

用于:

type stamp = int

[<CustomEquality; CustomComparison>]
type MyUnionType =
    | MyUnionType of stamp * (int -> int) 

    static member Stamp (MyUnionType (s,_)) = s

    override x.Equals y = equalsOn MyUnionType.Stamp x y
    override x.GetHashCode() = hashOn MyUnionType.Stamp x
    interface System.IComparable with
      member x.CompareTo y = compareOn MyUnionType.Stamp x y
Run Code Online (Sandbox Code Playgroud)

Jar*_*Par 5

之所以与使用有关x.值xy用作同一回调的参数:f xf y.的类型的y在该表达是已知的T,因此x也必须是类型兼容的与T如此F#选择T