是否有可能以这样的方式设计我的类型,我可以这样写:
let fieldValues = [nameField, VText "string"; ageField, VInteger 13]
但不是这个:(从某种意义上说,这将是一个编译时错误):
let fieldValues = [nameField, VInteger 13; ageField, VText "string"]
type value =
| VText of string
| VInteger of int
type ty =
| TText
| TInteger
type field = { Id: int; Type: ty; Name: string }
let nameField = { Id=1; Type=TText; Name="Name" }
let ageField = { Id=2; Type=TInteger; Name="Age" }