comparison src/monoize.sml @ 993:10114d7b7477

SELECT DISTINCT; eta expansion during Cjrization
author Adam Chlipala <adamc@hcoop.net>
date Tue, 06 Oct 2009 15:39:27 -0400
parents d1dbb9a3c804
children 16f7cb0891b6
comparison
equal deleted inserted replaced
992:b825d843b22d 993:10114d7b7477
1769 (L.CRecord (_, stables), _)), _), 1769 (L.CRecord (_, stables), _)), _),
1770 sexps) => 1770 sexps) =>
1771 let 1771 let
1772 fun sc s = (L'.EPrim (Prim.String s), loc) 1772 fun sc s = (L'.EPrim (Prim.String s), loc)
1773 val s = (L'.TFfi ("Basis", "string"), loc) 1773 val s = (L'.TFfi ("Basis", "string"), loc)
1774 val b = (L'.TFfi ("Basis", "bool"), loc)
1774 val un = (L'.TRecord [], loc) 1775 val un = (L'.TRecord [], loc)
1775 fun gf s = (L'.EField ((L'.ERel 0, loc), s), loc) 1776 fun gf s = (L'.EField ((L'.ERel 0, loc), s), loc)
1776 1777
1777 fun doTables tables = 1778 fun doTables tables =
1778 let 1779 let
1804 let 1805 let
1805 val sexps = ListMergeSort.sort 1806 val sexps = ListMergeSort.sort
1806 (fn ((x, _), (y, _)) => String.compare (x, y) = GREATER) sexps 1807 (fn ((x, _), (y, _)) => String.compare (x, y) = GREATER) sexps
1807 in 1808 in
1808 ((L'.EAbs ("r", 1809 ((L'.EAbs ("r",
1809 (L'.TRecord [("From", s), 1810 (L'.TRecord [("Distinct", b),
1811 ("From", s),
1810 ("Where", s), 1812 ("Where", s),
1811 ("GroupBy", un), 1813 ("GroupBy", un),
1812 ("Having", s), 1814 ("Having", s),
1813 ("SelectFields", un), 1815 ("SelectFields", un),
1814 ("SelectExps", (L'.TRecord (map (fn (x, _) => (x, s)) sexps), loc))], 1816 ("SelectExps", (L'.TRecord (map (fn (x, _) => (x, s)) sexps), loc))],
1815 loc), 1817 loc),
1816 s, 1818 s,
1817 strcat [sc "SELECT ", 1819 strcat [sc "SELECT ",
1820 (L'.ECase (gf "Distinct",
1821 [((L'.PCon (L'.Enum,
1822 L'.PConFfi {mod = "Basis",
1823 datatyp = "bool",
1824 con = "True",
1825 arg = NONE},
1826 NONE), loc),
1827 (L'.EPrim (Prim.String "DISTINCT "), loc)),
1828 ((L'.PCon (L'.Enum,
1829 L'.PConFfi {mod = "Basis",
1830 datatyp = "bool",
1831 con = "False",
1832 arg = NONE},
1833 NONE), loc),
1834 (L'.EPrim (Prim.String ""), loc))],
1835 {disc = b, result = s}), loc),
1818 strcatComma (map (fn (x, t) => 1836 strcatComma (map (fn (x, t) =>
1819 strcat [ 1837 strcat [
1820 (L'.EField (gf "SelectExps", x), loc), 1838 (L'.EField (gf "SelectExps", x), loc),
1821 sc (" AS _" ^ x) 1839 sc (" AS _" ^ x)
1822 ]) sexps 1840 ]) sexps