§ 4.4. Functional record update
SML# contains functional record update expressions, whose syntax is given below.
This expression creates a new record by modifying the value of
each label
# fun f modify x = x # {X=3};
val f = _ : ['a#{X:'b}, 'b. 'a -> 'a]
The following is a useful idiom in record programming.
# fun reStructure (p as {Salary,...}) = p # {Salary=Salary * (1.0 - 0.0803)};
val f = _ : ['a#{Salary:real}. 'a -> 'a]
Function reStructure takes an employee record p and reduces its Salary field by 8.03%. As seen in its typing, this function can be applied to any record as far as it contains a ,Salary field.