comparison src/sqlcache.sml @ 2240:88cc0f44c940

Rename C functions and remove functors nested inside modules.
author Ziv Scully <ziv@mit.edu>
date Sun, 19 Jul 2015 19:03:11 -0700
parents f70a91f7810d
children da7d026d1a94
comparison
equal deleted inserted replaced
2239:f70a91f7810d 2240:88cc0f44c940
205 | Combo (j, fs) => Combo (j, map (mapFormula mf) fs) 205 | Combo (j, fs) => Combo (j, map (mapFormula mf) fs)
206 206
207 207
208 (* SQL analysis. *) 208 (* SQL analysis. *)
209 209
210 structure CmpKey : ORD_KEY = struct 210 structure CmpKey = struct
211 211
212 type ord_key = Sql.cmp 212 type ord_key = Sql.cmp
213 213
214 val compare = 214 val compare =
215 fn (Sql.Eq, Sql.Eq) => EQUAL 215 fn (Sql.Eq, Sql.Eq) => EQUAL
244 EQUAL => compare (xs, ys) 244 EQUAL => compare (xs, ys)
245 | ord => ord) 245 | ord => ord)
246 246
247 end 247 end
248 *) 248 *)
249
250 functor OptionKeyFn (K : ORD_KEY) : ORD_KEY = struct
251
252 type ord_key = K.ord_key option
253
254 val compare =
255 fn (NONE, NONE) => EQUAL
256 | (NONE, _) => LESS
257 | (_, NONE) => GREATER
258 | (SOME x, SOME y) => K.compare (x, y)
259
260 end
261
262 functor TripleKeyFn (structure I : ORD_KEY
263 structure J : ORD_KEY
264 structure K : ORD_KEY)
265 : ORD_KEY where type ord_key = I.ord_key * J.ord_key * K.ord_key = struct
266
267 type ord_key = I.ord_key * J.ord_key * K.ord_key
268
269 fun compare ((i1, j1, k1), (i2, j2, k2)) =
270 case I.compare (i1, i2) of
271 EQUAL => (case J.compare (j1, j2) of
272 EQUAL => K.compare (k1, k2)
273 | ord => ord)
274 | ord => ord
275
276 end
277 249
278 val rec chooseTwos : 'a list -> ('a * 'a) list = 250 val rec chooseTwos : 'a list -> ('a * 'a) list =
279 fn [] => [] 251 fn [] => []
280 | x :: ys => map (fn y => (x, y)) ys @ chooseTwos ys 252 | x :: ys => map (fn y => (x, y)) ys @ chooseTwos ys
281 253