[Ur] Which is the syntax for record updating

Adam Chlipala adamc at csail.mit.edu
Sat Mar 7 09:07:45 EST 2015


On 03/07/2015 07:43 AM, Gabriel Riba wrote:
> Until now I have used the following strategy for updating records
>
> val newRec = r -- #Key -- #Value ++ {Key = k1, Value = v1}
>
>
> but I guess that there must be a simpler syntax for this.

That's about the simplest syntax there is at the moment, though it is 
also possible to define a library function that hides use of the [---] 
operator to make the syntax a bit more compact.

fun overwrite [a] [b] [a ~ b] (r : $(a ++ b)) (r' : $b) : $(a ++ b) =
     r --- b ++ r'

val test = overwrite {A = 1, B = "", C = 2.3} {A = 8, C = 4.5}




More information about the Ur mailing list