type TotalSizeToken = TotalSizeToken with
static member TotalSize(_: TotalSizeToken, (a,b,c,d,e)): int = a*b*c*d*e
static member TotalSize(_: TotalSizeToken, (a,b,c,d)): int = a*b*c*d
static member TotalSize(_: TotalSizeToken, (a,b,c)): int = a*b*c
static member TotalSize(_: TotalSizeToken, (a,b)): int = a*b
static member TotalSize(_: TotalSizeToken, x: int): int = x
let inline size_to_total_size x =
((^s) : (static member TotalSize: TotalSizeToken * ^s -> int) TotalSizeToken, x)
let t = size_to_total_size (1,5) // Error: Expecting a type supporting the operator TotalSize, but given a tuple type.
我沒有想到size_to_total_size
中的x
參數需要TotalSize成員。這感覺就像一個編譯器錯誤。如何獲得具有可變數量參數的整數元組的產品?
我不知道如何讓這個工作。有任何想法嗎?