open Versioned.Make(struct
con key = [Id = int]
con data = [Nam = string, ShoeSize = int]
val key = {Id = _}
val data = {Nam = {Inj = _,
Eq = _},
ShoeSize = {Inj = _,
Eq = _}}
end)
fun retro vr =
ks <- keysAt vr;
ks <- List.mapM (fn r => fso <- archive vr r; return (r.Id, fso)) ks;
return
{List.mapX (fn (k, r) =>
{[k]}: {case r of
None => Whoa!
| Some r => {[r.Nam]}, {[r.ShoeSize]}}
) ks}
fun expandKey k =
name <- source "";
shoeSize <- source "";
return {Key = k, Nam = name, ShoeSize = shoeSize}
fun main () =
ks0 <- keys;
ks0 <- List.mapM (fn r => expandKey r.Id) ks0;
ks <- source ks0;
id <- source "";
name <- source "";
shoeSize <- source "";
times <- updateTimes;
return
{[kr.Key]}:
) ks)}/>
Add one:
Id:
Name:
Shoe size:
id <- get id;
name <- get name;
shoeSize <- get shoeSize;
rpc (insert {Id = readError id, Nam = name,
ShoeSize = readError shoeSize});
cur <- get ks;
kr <- expandKey (readError id);
set ks (kr :: cur)}/>