例如,如果你有
datatype 'a DT =
thingy of {field1: int, field2: int}
| Empty DT;
你怎么能够创造" thingy"在功能中填写其字段?假设您拥有每个字段所需的值。
答案 0 :(得分:0)
- datatype 'a DT = thingy of {x: int, y: int} | Empty;
datatype 'a DT = Empty | thingy of {x:int, y:int}
- thingy {x = 5, y = 4};
val it = thingy {x=5,y=4} : 'a DT
- fun f x y = thingy {x = x, y = y};
val f = fn : int -> int -> 'a DT