-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Add Relational structure. It is not part of the Standard ML Basis library, but contains various functions and types that are useful for relational query evaluation.
signature RELATIONAL =
sig
(* Values of the "descending" type sort in reverse order to the type that
they wrap. Thus 'order DESC i' sorts elements in the opposite direction to
'order i'. *)
datatype descending = DESC of 'a
(* "compare (x, y)" returns LESS, EQUAL, or GREATER according to
* whether its first argument is less than, equal to, or greater
* than the second.
*
* Comparisons are based on the structure of the type
* α. Primitive types are compared using their natural order;
* Option types compare with NONE last; Tuple types compare
* lexicographically; Record types compare lexicographically, with
* the fields compared in alphabetical order; List values compare
* lexicographically; Bag values compare lexicographically, the
* elements appearing in an order that is arbitrary but is
* consistent for each particular value. *)
val compare : α * α → order
(* "count list" returns the number of elements in list. Often used
* with `group`, for example `from e in emps group e.deptno compute
* countId = count`. *)
val count : int list → int
(* "empty list" returns whether the list is empty, for example `from
* d in depts where empty (from e where e.deptno = d.deptno)`. *)
val empty : α list → bool
(* "max list" returns the greatest element of list. Often used with
* `group`, for example `from e in emps group e.deptno compute maxId
* = max over e.id`. *)
val max : α list → α
(* "min list" returns the least element of list. Often used with
* `group`, for example `from e in emps group e.deptno compute minId
* = min over e.id`. *)
val min : α list → α
(* "nonEmpty list" returns whether the list has at least one
* element, for example `from d in depts where nonEmpty (from e
* where e.deptno = d.deptno)`. *)
val nonEmpty : α list → bool
(* "only list" returns the sole element of `list`, for example `from
* e in emps yield only (from d where d.deptno = e.deptno)`. Raises
* `Empty` if the list does not have exactly one element. *)
val only : α list → α
(* "e elem collection" returns whether `e` is a member of
* `collection`. *)
val elem : α * α bag → bool | α * α list → bool
(* "e notelem collection" returns whether `e` is not a member of
* `collection`. *)
val notelem : α * α bag → bool | α * α list → bool
(* "sum list" returns the sum of the elements of `list`. Often used
* with `group`, for example `from e in emps group e.deptno compute
* sumId = sum over e.id`. *)
val sum : int list → int
end
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels