diff src/monoize.sml @ 1602:e44be6ece475

COALESCE
author Adam Chlipala <adam@chlipala.net>
date Sat, 19 Nov 2011 10:43:57 -0500
parents 34364e383bed
children da788bd72c9e
line wrap: on
line diff
--- a/src/monoize.sml	Sat Nov 19 10:26:19 2011 -0500
+++ b/src/monoize.sml	Sat Nov 19 10:43:57 2011 -0500
@@ -2808,6 +2808,28 @@
              (L.ECApp (
               (L.ECApp (
                (L.ECApp (
+                (L.EFfi ("Basis", "sql_coalesce"), _), _),
+                _), _),
+               _), _),
+              _), _)) =>
+            let
+                val s = (L'.TFfi ("Basis", "string"), loc)
+                fun sc s = (L'.EPrim (Prim.String s), loc)
+            in
+                ((L'.EAbs ("x1", s, (L'.TFun (s, s), loc),
+                           (L'.EAbs ("x1", s, s,
+                                     strcat [sc "COALESCE(",
+                                             (L'.ERel 1, loc),
+                                             sc ",",
+                                             (L'.ERel 0, loc),
+                                             sc ")"]), loc)), loc),
+                 fm)
+            end
+
+          | (L.ECApp (
+             (L.ECApp (
+              (L.ECApp (
+               (L.ECApp (
                 (L.EFfi ("Basis", "sql_if_then_else"), _), _),
                 _), _),
                _), _),