[MLton-commit] r5193

Wesley Terpstra wesley at mlton.org
Wed Feb 14 08:41:58 PST 2007


outline my plan for binding user functions
----------------------------------------------------------------------

A   mltonlib/trunk/ca/terpstra/sqlite3/function.sml
U   mltonlib/trunk/ca/terpstra/sqlite3/sql.sig
U   mltonlib/trunk/ca/terpstra/sqlite3/sql.sml
U   mltonlib/trunk/ca/terpstra/sqlite3/sqlite.mlb

----------------------------------------------------------------------

Added: mltonlib/trunk/ca/terpstra/sqlite3/function.sml
===================================================================
--- mltonlib/trunk/ca/terpstra/sqlite3/function.sml	2007-02-14 16:20:20 UTC (rev 5192)
+++ mltonlib/trunk/ca/terpstra/sqlite3/function.sml	2007-02-14 16:41:57 UTC (rev 5193)
@@ -0,0 +1,3 @@
+structure Function =
+   struct
+   end

Modified: mltonlib/trunk/ca/terpstra/sqlite3/sql.sig
===================================================================
--- mltonlib/trunk/ca/terpstra/sqlite3/sql.sig	2007-02-14 16:20:20 UTC (rev 5192)
+++ mltonlib/trunk/ca/terpstra/sqlite3/sql.sig	2007-02-14 16:41:57 UTC (rev 5193)
@@ -26,6 +26,9 @@
        *)
       structure Query :
          sig
+            type ('i, 'o) t
+            
+            (* don't look at this: *)
             type ('i, 'o, 'w, 'x, 'y, 'z) acc
             type ('v, 'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) output = 
                (('i, 'o, 'v, 'p,            'a, 'b) acc, 
@@ -36,7 +39,6 @@
                         ('j, 'o, 'a, 'b, ('j, 'k) pair, 'k) acc, 
                         'x, 'y, 'z) Fold.step1
             
-            type ('i, 'o) t
             val prepare: db -> string -> ((unit, unit, 'a, 'a, 'b, 'b) acc,
                                           ('i,   'o,   'c, 'd, 'e, 'f) acc, 
                                           ('i, 'o) t, 'g) Fold.t
@@ -104,4 +106,44 @@
       (* For simple queries you only run once, use: *)
       val simpleTable: db * string -> string vector vector
       val simpleExec: db * string -> unit
+      
+      (* This is used to create special user functions.
+       * Examples:
+       * local
+       *   open SQL.Function
+       * in
+       *   val f = fnS iI iR $ fn (i & r) => (Int.toString i ^ Real.toString r)
+       *   val g = fnX $ fn () => SQL.NULL
+       * end
+       *)
+(*
+      structure Function:
+         sig
+            type t
+            
+            (* Return types of the function *)
+            val fnB: (Word8Vector.vector, 'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
+            val fnR: (real,               'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
+            val fnI: (int,                'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
+            val fnZ: (Int64.int,          'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
+            val fnS: (string,             'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
+            val fnX: (storage,            'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
+            
+            val $ : 'a * ('a -> 'b) -> 'b
+            
+            (* Input parameters to the function *)
+            val iB: (Word8Vector.vector, 'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
+            val iR: (real,               'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
+            val iI: (int,                'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
+            val iZ: (Int64.int,          'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
+            val iS: (string,             'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
+            val iX: (storage,            'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
+            
+            (* Variadic functions *)
+            val iAB: ...
+         end
+      
+      val registerFunction:  string * Function.t option -> unit
+      val registerCollation: string * (string * string -> order) option -> unit
+*)
    end

Modified: mltonlib/trunk/ca/terpstra/sqlite3/sql.sml
===================================================================
--- mltonlib/trunk/ca/terpstra/sqlite3/sql.sml	2007-02-14 16:20:20 UTC (rev 5192)
+++ mltonlib/trunk/ca/terpstra/sqlite3/sql.sml	2007-02-14 16:41:57 UTC (rev 5193)
@@ -9,6 +9,7 @@
       exception Error = Prim.Error
       
       structure Query = Query
+      structure Function = Function
       
       val version = Prim.version
       

Modified: mltonlib/trunk/ca/terpstra/sqlite3/sqlite.mlb
===================================================================
--- mltonlib/trunk/ca/terpstra/sqlite3/sqlite.mlb	2007-02-14 16:20:20 UTC (rev 5192)
+++ mltonlib/trunk/ca/terpstra/sqlite3/sqlite.mlb	2007-02-14 16:41:57 UTC (rev 5193)
@@ -17,6 +17,7 @@
    sql.sig
    local
      query.sml
+     function.sml
    in
      sql.sml
    end




More information about the MLton-commit mailing list