如何实现DivideByInt

Mur*_*ray 3 f#

我正在尝试编写一个自定义DivideByInt,如下所示

type Pair = Pair of int * int with
    static member DivideByInt pair int = pair


[<EntryPoint>]
let main argv =
    LanguagePrimitives.DivideByInt (Pair(1,2)) 1 
    |> ignore 
    0

// compiler error: "FS0001: Method or object constructor 'DivideByInt' not found"
Run Code Online (Sandbox Code Playgroud)

为什么编译器找不到Pair.DivideByInt?

Mur*_*ray 6

Pair.DivideByInt 必须以元组作为输入

更正后的版本:

type Pair = Pair of int * int with
    static member DivideByInt (pair, int) = pair
Run Code Online (Sandbox Code Playgroud)