comparison src/iflow.sml @ 1222:117f13bdc1fd

Express all query outputs using record literals
author Adam Chlipala <adamc@hcoop.net>
date Sun, 11 Apr 2010 12:45:15 -0400
parents 00e628854005
children 62af4cacd191
comparison
equal deleted inserted replaced
1221:00e628854005 1222:117f13bdc1fd
1424 in 1424 in
1425 (rvN, p, True, sis) 1425 (rvN, p, True, sis)
1426 end 1426 end
1427 | AllCols oe => 1427 | AllCols oe =>
1428 let 1428 let
1429 val (p', rvN) = 1429 val (ts, es, rvN) =
1430 foldl (fn (si, (p, rvN)) => 1430 foldl (fn (si, (ts, es, rvN)) =>
1431 let 1431 case si of
1432 val (p', rvN) = 1432 SqField (v, f) =>
1433 case si of 1433 let
1434 SqField (v, f) => (Reln (Eq, [Proj (Proj (oe, v), f), 1434 val fs = getOpt (SM.find (ts, v), SM.empty)
1435 Proj (rvOf v, f)]), rvN) 1435 in
1436 | SqExp (e, f) => 1436 (SM.insert (ts, v, SM.insert (fs, f, Proj (rvOf v, f))), es, rvN)
1437 end
1438 | SqExp (e, f) =>
1439 let
1440 val (e, rvN) =
1437 case expIn (e, rvN) of 1441 case expIn (e, rvN) of
1438 (inr p, rvN) => (Cond (Proj (oe, f), p), rvN) 1442 (inr _, rvN) =>
1439 | (inl e, rvN) => (Reln (Eq, [Proj (oe, f), e]), rvN) 1443 let
1440 in 1444 val (rvN, e) = rv rvN
1441 (And (p, p'), rvN) 1445 in
1442 end) 1446 (e, rvN)
1443 (True, rvN) (#Select r) 1447 end
1448 | (inl e, rvN) => (e, rvN)
1449 in
1450 (ts, SM.insert (es, f, e), rvN)
1451 end)
1452 (SM.empty, SM.empty, rvN) (#Select r)
1453
1454 val p' = Reln (Eq, [oe, Recd (map (fn (t, fs) => (t, Recd (SM.listItemsi fs)))
1455 (SM.listItemsi ts)
1456 @ SM.listItemsi es)])
1444 in 1457 in
1445 (rvN, And (p, p'), True, []) 1458 (rvN, And (p, p'), True, [])
1446 end 1459 end
1447 1460
1448 val (rvN, p, wp, outs) = 1461 val (rvN, p, wp, outs) =