[Ur] Default settings using a generic record update
Mark Clements
mark.clements at ki.se
Mon Oct 28 15:27:46 EDT 2019
I would like to set defaults for a JavaScript library within Ur/Web. I
have the following code that fails on the last line: can anyone suggest
how to make defaultSetting more generic, please?
Kindly, Mark.
--------
fun update
[keep] [change] [keep ~ change]
(xs : $(keep ++ change)) (ys : $change)
: $(keep ++ change) =
xs --- change ++ ys
fun defaultSetting args =
update {A=1, B=1} args
(*
fun defaultSetting [a] (args : $a) =
update {A=1, B=2} args
*)
val _ = defaultSetting {A=2} (* {A=2, B=1} *)
val _ = defaultSetting {B=2} (* {A=1, B=2} *)
När du skickar e-post till Karolinska Institutet (KI) innebär detta att KI kommer att behandla dina personuppgifter. Här finns information om hur KI behandlar personuppgifter<https://ki.se/medarbetare/integritetsskyddspolicy>.
Sending email to Karolinska Institutet (KI) will result in KI processing your personal data. You can read more about KI’s processing of personal data here<https://ki.se/en/staff/data-protection-policy>.
More information about the Ur
mailing list