F# - 盒装元组上的模式匹配

Gos*_*win 1 f# pattern-matching

如何在盒装元组上进行模式匹配?或者有更好的方法来做这样的事情(简化示例):

open System.Drawing

let coerceColor a =
    match box a with
    | :? Color as c -> c
    | (:? int as r),(:? int as g),(:? int as b) -> Color.FromArgb(r,g,b)
    | _ -> failwith "Cannot coerce color"
Run Code Online (Sandbox Code Playgroud)

Gus*_*Gus 5

let coerceColor a =
    match box a with
    | :? Color as c -> c
    | :? (int*int*int) as t -> t |> Color.FromArgb
    | _ -> failwith "Cannot coerce color"
Run Code Online (Sandbox Code Playgroud)

但是如果我可以改变设计,我宁愿使用DU或者带有重载的静态成员.