NAME
Language::MuldisD::Core - Muldis D core data types and operators
VERSION
This document is Language::MuldisD::Core version 0.13.0.
PREFACE
This document is part of the Muldis D language specification, whose root document is Language::MuldisD; you should read that root document before you read this one, which provides subservient details.
DESCRIPTION
Muldis D has a mandatory core set of system-defined (eternally available) entities, which is referred to as the Muldis D core or the core; they are the minimal entities that all Muldis D implementations need to provide; they are mutually self-describing and are used to bootstrap the language; any entities outside the core, called Muldis D extensions, are non-mandatory and are defined in terms of the core or each other, but the reverse isn't true.
This current Core
document features the boolean, order, integer, rational, bit string, and character string types and operators, plus the tuple and relation type constructors (and quasi- variants) and operators, plus the type system minimal and maximal types, plus the special types used to define the system catalog, and the polymorphic operators that all types, or some types including core types, have defined over them.
Extensions are in these other documents: Language::MuldisD::Ext::Temporal, Language::MuldisD::Ext::Spatial.
TYPE SUMMARY
Following are all the data types and data type factories described in this document, arranged in a type graph according to their proper sub|supertype relationships:
sys.Core.Universal.Universal
sys.Core.Universal.Empty
sys.Core.Scalar.Scalar
sys.Core.Ordered.Ordered
# The following are all regular ordered scalar types.
sys.Core.Bool.Bool
sys.Core.Order.Order
sys.Core.Int.Int
sys.Core.Int.UInt
sys.Core.Int.PInt
sys.Core.Rat.Rat
sys.Core.Rat.URat
sys.Core.Rat.PRat
sys.Core.Rat.BRat
sys.Core.Rat.DRat
sys.Core.Blob.Blob
sys.Core.Blob.NEBlob
sys.Core.Text.Text
sys.Core.Text.NEText
# The following are all nonscalar type factories.
sys.Core.Tuple.Tuple
sys.Core.Tuple.D0
sys.Core.Tuple.SetElem
sys.Core.Tuple.SeqElem
sys.Core.Tuple.BagElem
sys.Core.Tuple.Database
sys.Core.Relation.Relation
sys.Core.Relation.D0
sys.Core.Relation.Set
sys.Core.Relation.Maybe
sys.Core.Relation.Seq
sys.Core.Relation.Bag
# The following are all quasi-nonscalar type factories.
sys.Core.QuasiTuple.QuasiTuple
sys.Core.QuasiTuple.D0
sys.Core.QuasiTuple.QuasiSetElem
sys.Core.QuasiTuple.QuasiSeqElem
sys.Core.QuasiTuple.QuasiBagElem
sys.Core.QuasiRelation.QuasiRelation
sys.Core.QuasiRelation.D0
sys.Core.QuasiRelation.QuasiSet
sys.Core.QuasiRelation.QuasiMaybe
sys.Core.QuasiRelation.QuasiSeq
sys.Core.QuasiRelation.QuasiBag
Note that sys.Core.Universal.Empty
is a proper subtype of all of the other types in this graph, but every other type has only one immediate supertype shown, and hence the graph of them is a simple hierarchy.
These system-defined subtypes are specific to defining the system catalog, more or less:
sys.Core.Universal.Universal
sys.Core.Universal.Empty
sys.Core.Scalar.Scalar
# The following is actually a union over many scalar types.
sys.Core.Cat.ScalarLiteral
sys.Core.Ordered.Ordered
# The following are all regular ordered scalar types.
sys.Core.Cat.Name
sys.Core.Cat.NameChain
sys.Core.Cat.FlattenedNameChain
# The following are all regular non-ordered scalar types.
sys.Core.Cat.E_RM
sys.Core.Cat.E_TK
sys.Core.Cat.E_TDM
sys.Core.Cat.E_ENK
sys.Core.Cat.E_PSAK
sys.Core.Tuple.Tuple
# The following are all regular tuple types.
sys.Core.Cat.RatRoundRule
sys.Core.Cat.Type
sys.Core.Cat.ExprNode
sys.Core.Cat.InnerFunc
sys.Core.Cat.Func
sys.Core.Cat.UpdateStmt
sys.Core.Cat.InnerUpdateOper
sys.Core.Cat.UpdateOper
sys.Core.Cat.ProcStmtArg
sys.Core.Cat.ProcStmt
sys.Core.Cat.InnerProc
sys.Core.Cat.Proc
sys.Core.Cat.Exception
sys.Core.Relation.Relation
# The following are all regular relation types.
sys.Core.Cat.NameTypeMap
sys.Core.Cat.NameExprMap
sys.Core.Cat.AttrRenameMap
sys.Core.Cat.ExprSet
sys.Core.Cat.ExprTree
sys.Core.Cat.InnerFuncSet
sys.Core.Cat.InnerFuncTree
sys.Core.Cat.MultiUpdateStmt
sys.Core.Cat.InnerUpdateOperSet
sys.Core.Cat.InnerUpdateOperTree
sys.Core.Cat.ProcStmtArgSet
sys.Core.Cat.InnerProcTree
sys.Core.Relation.Set
# The following are all regular set types.
sys.Core.Cat.SetOfName
sys.Core.Cat.SetOfSetOfName
sys.Core.Cat.SetOfNameExprMap
sys.Core.Cat.SetOfNameChain
sys.Core.Relation.Seq
# The following are all regular sequence types.
sys.Core.Cat.NESeqOfName
sys.Core.Cat.SeqOfProcStmt
These system-defined subtypes have also been defined for convenience, as they are anticipated to be frequently used; in fact, most of them are used as the declared parameter types of various core operators:
sys.Core.Universal.Universal
sys.Core.Universal.Empty
sys.Core.Scalar.Scalar
sys.Core.Ordered.Ordered
sys.Core.Int.Int
sys.Core.Int.UInt
sys.Core.Int.PInt
# These are all finite integer types.
sys.Core.Spec.PInt1_4
sys.Core.Spec.PInt2_N
sys.Core.Spec.PInt2_36
sys.Core.Relation.Relation
sys.Core.Relation.Set
# The following are all regular set types.
sys.Core.Spec.SetOfBool
sys.Core.Spec.SetOfInt
sys.Core.Spec.SetOfRat
sys.Core.Spec.SetOfBlob
sys.Core.Spec.SetOfText
# The following are all nonscalar type factories.
sys.Core.Spec.SetOfRelation
sys.Core.Relation.Maybe
# The following are all regular maybe types.
sys.Core.Spec.MaybeOfBool
sys.Core.Spec.MaybeOfInt
sys.Core.Spec.MaybeOfRat
sys.Core.Spec.MaybeOfBlob
sys.Core.Spec.MaybeOfText
sys.Core.Relation.Seq
# The following are all regular sequence types.
sys.Core.Spec.SeqOfBool
sys.Core.Spec.SeqOfInt
sys.Core.Spec.SeqOfRat
sys.Core.Spec.SeqOfBlob
sys.Core.Spec.SeqOfText
sys.Core.Relation.Bag
# The following are all regular bag types.
sys.Core.Spec.BagOfBool
sys.Core.Spec.BagOfInt
sys.Core.Spec.BagOfRat
sys.Core.Spec.BagOfBlob
sys.Core.Spec.BagOfText
# The following are all nonscalar type factories.
sys.Core.Spec.BagOfRelation
sys.Core.QuasiRelation.QuasiRelation
sys.Core.QuasiRelation.QuasiSet
# The following are all quasi-nonscalar type factories.
sys.Core.Spec.QuasiSetOfRelation
Note that, in later operator documentation, if you see something like Foo{Bar}
as a declared type, it corresponds to sys.Core.Spec.FooOfBar
.
SYSTEM-DEFINED CORE MAXIMAL AND MINIMAL DATA TYPES
These core data types are special and are the only Muldis D types that are neither scalar nor nonscalar nor quasi-nonscalar types. They are all system-defined and it is impossible for users to define more types of this nature.
sys.Core.Universal.Universal
The Universal
type is the maximal type of the entire Muldis D type system, and contains every value that can possibly exist. Every other type is implicitly a proper subtype of Universal
, and Universal
is implicitly a union type over all other types. Its default value is Bool:false
. The cardinality of this type is infinity.
sys.Core.Universal.Empty
The Empty
type is the minimal type of the entire Muldis D type system, and is the only type that contains exactly zero values. Every other type is implicitly a proper supertype of Empty
and Empty
is implicitly an intersection type over all other types. It has no default value. The cardinality of this type is zero.
SYSTEM-DEFINED CORE PSEUDO-TYPES
These are pseudo-types (that is, they aren't types at all) which represent generic contexts that could accept a multiplicity of types, but are not the same as contexts named after some actual types. For example, they are used as the declared parameter types of some dyadic polymorphic operators to refer to, per instance, 2 given types that need to be compatible, but the compatibility isn't simply defined by a "are any 2 subtypes of" such as is true with most operators. They are all system-defined and it is impossible for users to define more types of this nature.
sys.Core.Some.Universal
Contexts defined by the Some.Universal
pseudo-type accept values of potentially any type of Universal
.
sys.Core.Some.ScaTupRel
Contexts defined by the Some.ScaTupRel
pseudo-type accept values of potentially any type of Scalar
or Tuple
or Relation
.
sys.Core.Some.Ordered
Contexts defined by the Some.Ordered
pseudo-type accept values of potentially any type of Ordered
.
SYSTEM-DEFINED CORE SCALAR DATA TYPES
These core scalar data types are the most fundamental Muldis D types. Each one has zero possreps, and hence has no named components that can be referenced. Concrete Muldis D provides a specific syntax per type to select a value of one of these types, which does not look like a routine invocation, but rather like a scalar literal in a typical programming language; details of that syntax are not given here, but in Language::MuldisD::Grammar. Abstract Muldis D as hosted in another language will essentially use literals of corresponding host language types, whatever they use for eg booleans and integers and character strings, but tagged with extra meta-data if the host language is more weakly typed or lacks one-to-one type correspondence; see Language::MuldisD::PerlHosted for a Perl-based example.
sys.Core.Scalar.Scalar
The Scalar
type is the maximal type of all Muldis D scalar types, and contains every scalar value that can possibly exist. Every other scalar type is implicitly a proper subtype of Scalar
, and Scalar
is implicitly a union type over all other scalar types. Its default value is Bool:false
. The cardinality of this type is infinity.
sys.Core.Ordered.Ordered
The Ordered
type is a proper subtype of Scalar
that is a proper supertype of all scalar types that are considered ordered. Any scalar types which consider themselves ordered, which happens to include every system-defined core scalar root type, will explicitly declare themselves as subtypes of Ordered
in their type definitions; the definition of Ordered
does not specify what other types it is a union over. Its default value is Bool:false
. The cardinality of this type is infinity.
sys.Core.Bool.Bool
A Bool
is an enumeration consisting of the 2 values Bool:false
and Bool:true
. It represents a truth value, and is the result type of any is_equal
or is_not_equal
routine; it is the only essential scalar data type of a D language. Its default and minimum value is Bool:false
; its maximum value is Bool:true
. The cardinality of this type is 2.
sys.Core.Order.Order
An Order
is an enumeration consisting of the 3 values Order:increase
, Order:same
, Order:decrease
. It is the result type of any comparison
routine that is used on 2 values of a sys.Core.Ordered.Ordered
subtype. Its default value is Order:same
; its minimum and maximum values are, respectively, Order:increase
and Order:decrease
. The cardinality of this type is 3.
sys.Core.Int.Int
An Int
is a single exact integral number of any magnitude. Its default value is zero; its minimum and maximum values are conceptually infinities and practically impossible. The cardinality of this type is infinity; to define a most-generalized finite Int
subtype, you must specify the 2 integer end-points of the inclusive range that all its values are in.
sys.Core.Int.UInt
A UInt
(unsigned / non-negative integer) is a proper subtype of Int
where all member values are greater than or equal to zero. Its minimum value is zero.
sys.Core.Int.PInt
A PInt
(positive integer) is a proper subtype of UInt
where all member values are greater than zero. Its default and minimum value is 1.
sys.Core.Rat.Rat
A Rat
is a single exact rational number of any magnitude. It is conceptually a numerator (Int
) divided by a denominator (PInt
). Its default value is zero; its minimum and maximum values are conceptually infinities and practically impossible. The cardinality of this type is infinity; to define a most-generalized finite Rat
subtype, you must specify the greatest magnitude value denominator, plus the the 2 integer end-points of the inclusive range of the value numerator. Common subtypes specify that all denominators are positive powers of a particular radix (PInt
), where the radix is usually either 2 or 10; types such as these will easily map exactly to common human or physical numeric representations, so they tend to perform better.
sys.Core.Rat.URat
A URat
(unsigned / non-negative rational) is a proper subtype of Rat
where all member values are greater than or equal to zero. Its minimum value is zero.
sys.Core.Rat.PRat
A PRat
(positive rational) is a proper subtype of URat
where all member values are greater than zero. Its default value is 1.
sys.Core.Rat.BRat
A BRat
(binary rational) is a proper subtype of Rat
where the radix is 2; it is the best option to exactly represent rational numbers that are conceptually binary or octal or hexadecimal.
sys.Core.Rat.DRat
A DRat
(decimal rational) is a proper subtype of Rat
where the radix is 10; it is the best option to exactly represent rational numbers that are conceptually the decimal numbers that humans typically work with.
sys.Core.Blob.Blob
A Blob
is an undifferentiated string of bits. Its default and minimum value is the empty string; its maximum value is an infinite-length string and practically impossible. The cardinality of this type is infinity; to define a most-generalized finite Blob
subtype, you must specify a maximum length in bits that the subtype's strings are.
sys.Core.Blob.NEBlob
A NEBlob
(non-empty blob) is a proper subtype of Blob
where its length in bits must be at least 1; it can be any Blob
except for the empty string. Its default and minimum value is a single zero bit.
sys.Core.Text.Text
A Text
is a string of characters. Its default and minimum value is the empty string; its maximum value is an infinite-length string and practically impossible. Note that there is only one system-defined character repertoire for Text
types, which is the newest Unicode repertoire (5.0.0). The cardinality of this type is infinity; to define a most-generalized finite Text
subtype, you must specify a maximum length in characters (that is, eg, in NFC graphemes) that the subtype's strings are.
sys.Core.Text.NEText
A NEText
(non-empty text) is a proper subtype of Text
where its length in characters must be more than zero; it can be any Text
except for the empty string. Its default value is a single "space" character; its minimum value has one character, but which character that is depends on the default or current collation.
SYSTEM-DEFINED CORE NONSCALAR PARAMETERIZED DATA TYPES
These are only called nonscalar data types in a loose sense, because by themselves they are incomplete type definitions. Actual nonscalar data type definitions are derived from these by supplying the balance of the type definitions, such as what their attributes are and/or what their attribute types are. Associated with these incomplete type definitions are a set of system-defined routines that can be applied to values of any actual nonscalar types derived from them; such are called generic nonscalar operators. In the Muldis D type system, these incomplete nonscalar types are defined as union types over all actual types derived from them, and are proper supertypes of said.
Some actual nonscalar data types are system-defined, for use in defining the Muldis D system catalog / meta-model (see further below in the current document), and some others are system-defined for convenience since they are the types of many core operators (see further below in the current document), but all other actual nonscalar data types are user-defined. Users can also define their own incomplete nonscalar data types that are tuple or relation types.
sys.Core.Tuple.Tuple
The Tuple
type is the maximal type of all Muldis D tuple (nonscalar) types, and contains every tuple value that could possibly exist. A Tuple
is an unordered heterogeneous collection of 0..N named attributes (the count of attributes being its degree), where all attribute names are mutually distinct, and each attribute may be of distinct types; the mapping of a tuple's attribute names and their declared data types is called the tuple's heading. Its default value is the sole value of the sole tuple data type that has zero attributes. The cardinality of this type is equal to the product of the number of permutations drawable from the values of each of its attributes' declared data types; for a Tuple
subtype to be finite, all of its attribute types must be.
sys.Core.Tuple.D0
A Tuple.D0
is a proper subtype of Tuple
that has zero attributes; its cardinality is 1, and its only value is also the default value of Tuple
.
sys.Core.Tuple.SetElem
A SetElem
is a Tuple
with the same heading as Set
.
sys.Core.Tuple.SeqElem
A SeqElem
is a Tuple
with the same heading as Seq
.
sys.Core.Tuple.BagElem
A BagElem
is a Tuple
with the same heading as Bag
.
sys.Core.Tuple.Database
A Database
is a proper subtype of Tuple
where all of its attributes are each of relation types or of database types (the leaves of this recursion are all relation types); it is otherwise the same. It is also trivially a proper supertype of Tuple.D0
.
sys.Core.Relation.Relation
The Relation
type is the maximal type of all Muldis D relation (nonscalar) types, and contains every relation value that could possibly exist. A Relation
is analogous to a set of 0..N tuples where all tuples have the same heading (the degrees match and all attribute names and corresponding declared data types match), but that a Relation
data type still has its own corresponding heading (attribute names and declared data types) even when it consists of zero tuples. Its default value is the zero-tuple value of the sole relation data type that has zero attributes. Matters of its cardinality are generally the same as for Tuple
. A relation data type can also have (unique) keys each defined over a subset of its attributes, which constrain its set of values relative to there being no explicit keys, but having the keys won't turn an infinite relation type into a finite one.
sys.Core.Relation.D0
A Relation.D0
is a proper subtype of Relation
that has 0 attributes; its cardinality is 2, and its default value is the same as that of Relation
.
sys.Core.Relation.Set
A Set
is a proper subtype of Relation
that has 1 attribute, and its name is value
; it can be of any declared type. A Set
subtype is normally used by any system-defined N-ary operators where the order of their argument elements or result is not significant, and that duplicate values are not significant. Its default value has zero tuples. Note that, for any given complete Set subtype, Foo
, where its value
attribute has a declared type of Bar
, the type Foo
can be considered the power set of the type Bar
.
sys.Core.Relation.Maybe
A Maybe
is a proper subtype of Set
that may have at most one element; that is, it is a unary Relation
with a nullary key. Operators that work specifically with Maybe
subtypes can provide a syntactic shorthand for working with sparse data; so Muldis D has something which is conceptually close to SQL's nullable types without actually having 3-valued logic; it would probably be convenient for code that round-trips SQL by way of Muldis D to use the Maybe
type. Its default value has zero tuples.
sys.Core.Relation.Seq
A Seq
is a proper subtype of Relation
that has 2 attributes, and their names are index
and value
, where index
is a unary key and its declared type is a UInt
subtype (value
can be non-unique and of any declared type). A Seq is considered dense, and all index
values in one are numbered consecutively from 0 to 1 less than the count of tuples, like array indices in typical programming languages. A Seq
subtype is normally used by any system-defined N-ary operators where the order of their argument elements or result is significant (and duplicate values are significant); specifically, index
defines an explicit ordering for value
. Its default value has zero tuples.
sys.Core.Relation.Bag
A Bag
(or multiset) is a proper subtype of Relation
that has 2 attributes, and their names are value
and count
, where value
is a unary key (that can have any declared type) and count
is a PInt
subtype. A Bag
subtype is normally used by any system-defined N-ary operators where the order of their argument elements or result is not significant, but that duplicate values are significant; specifically, count
defines an explicit count of occurrences for value
, also known as that value's multiplicity. Its default value has zero tuples.
SYSTEM-DEFINED CORE QUASI-NONSCALAR PARAMETERIZED DATA TYPES
These quasi-nonscalar incomplete data type definitions correspond to their similarly-named (differing only by the Quasi
) nonscalar data types, and their use is intended to be limited to the few situations where the corresponding nonscalar data types can't be used. It should be noted in particular that there is no "QuasiDatabase" type, since all normal data or catalog databases should be composed of normal relations only; but all of the other nonscalar incomplete types have counterparts here.
sys.Core.QuasiTuple.QuasiTuple
A QuasiTuple
is like a Tuple
but that the declared types of its attributes can be anything at all. Its cardinality is infinite.
sys.Core.QuasiTuple.D0
A QuasiTuple.D0
is a proper subtype of QuasiTuple
in the corresponding manner to Tuple.D0
being a proper subtype of Tuple
. Its cardinality is 1.
sys.Core.QuasiTuple.QuasiSetElem
A QuasiSetElem
is a QuasiTuple
with the same heading as QuasiSet
.
sys.Core.QuasiTuple.QuasiSeqElem
A QuasiSeqElem
is a QuasiTuple
with the same heading as QuasiSeq
.
sys.Core.QuasiTuple.QuasiBagElem
A QuasiBagElem
is a QuasiTuple
with the same heading as QuasiBag
.
sys.Core.QuasiRelation.QuasiRelation
A QuasiRelation
is like a Relation
but that the declared types of its attributes can be anything at all. Its cardinality is infinite.
sys.Core.QuasiRelation.D0
A QuasiRelation.D0
is a proper subtype of QuasiRelation
in the corresponding manner to Relation.D0
being a proper subtype of Relation
. Its cardinality is 2.
sys.Core.QuasiRelation.QuasiSet
A QuasiSet
is a proper subtype of QuasiRelation
in the corresponding manner to Set
being a proper subtype of Relation
. Its cardinality is infinite.
sys.Core.QuasiRelation.QuasiMaybe
A QuasiMaybe
is a proper subtype of QuasiRelation
in the corresponding manner to Maybe
being a proper subtype of Relation
. Its cardinality is infinite.
sys.Core.QuasiRelation.QuasiSeq
A QuasiSeq
is a proper subtype of QuasiRelation
in the corresponding manner to Seq
being a proper subtype of Relation
. Its cardinality is infinite.
sys.Core.QuasiRelation.QuasiBag
A QuasiBag
is a proper subtype of QuasiRelation
in the corresponding manner to Bag
being a proper subtype of Relation
. Its cardinality is infinite.
SYSTEM-DEFINED CORE CATALOG SCALAR DATA TYPES
These core scalar data types are more special-purpose in nature and are intended for use in defining or working with the system catalog, which is mainly composed of nonscalar types built using these.
sys.Core.Cat.ScalarLiteral
A Cat.ScalarLiteral
is a union type over all the system-defined scalar types that are allowed to be used directly as hard-coded literal values in Muldis D expressions; 'directly' meaning not by way of explicitly invoking a selector function. Generally speaking, this union type includes all of the core scalar types that aren't themselves defined as union types. The full list that ScalarLiteral
unions is: Bool
, Order
, Int
, Rat
, Blob
, Text
, Cat.Name
, Cat.NameChain
, Cat.E_RM
, Cat.E_TK
, Cat.E_TDM
, Cat.E_ENK
, Cat.E_PSAK
, ...
sys.Core.Cat.Name
A Cat.Name
is a canonical short name for any kind of DBMS entity (or named component) when declaring it; this short name is sufficient to identify the entity within its immediate namespace. Similarly, a DBMS entity can often be invoked or referred to using just its Cat.Name
, depending on the context; other times, a Cat.NameChain
must be used instead to also qualify the reference with a namespace. Cat.Name
is the same as NEText
in all ways but that it is specifically intended for use in naming DBMS entities rather than being normal data.
sys.Core.Cat.NameChain
A Cat.NameChain
is a canonical long name for invoking or referring to a DBMS entity, when its name needs to be qualified with a namespace. A Cat.NameChain
has 2 possreps; one possrep is a sequence of 1..N Cat.Name
(represented by a Cat.NESeqOfName
), the 1..N elements being ordered from parent-most to child-most component name; the other possrep is a character string (represented by a Cat.FlattenedNameChain
) like when the elements of the first possrep are catenated (in order with the first element at the start of the string), with a period (.
) between the parts, and each part escaped such that backslashes, single-quotes, and periods are escaped as \b
, \q
and \p
respectively.
sys.Core.Cat.FlattenedNameChain
The Cat.FlattenedNameChain
type is used as the definition of the character string possrep of a Cat.NameChain
(see that type for details); while being a character string like Cat.Name
, the two are disjoint.
sys.Core.Cat.E_RM
A Cat.E_RM
(rounding method) is an enumeration consisting of the 5 values Cat.E_RM:half_up
, Cat.E_RM:to_even
, Cat.E_RM:to_floor
, Cat.E_RM:to_ceiling
, Cat.E_RM:to_zero
. When a value of some ordered type needs to be mapped into a proper subtype that doesn't contain that value, such as when mapping an arbitrary number to one with less precision, some rounding method is applied to determine which value of the subtype is to be mapped to while most accurately reflecting the original value. The Cat.E_RM
type enumerates the rounding methods that Muldis D operators can typically apply. With half_up
and to_even
(aka unbiased rounding, convergent rounding, statistician's rounding, or bankers' rounding), the original value will be mapped to the single target value that it is closest to, if there is one; otherwise, if it is exactly half-way between 2 adjacent target values, then half_up
will round upwards, and to_even
will round towards the nearest "even" one. With to_floor
, to_ceiling
, to_zero
(aka truncate), the original value will always be mapped to the single adjacent value that is lower than it, or higher than it, or towards "zero" from it, respectively. The default value of Cat.E_RM
is Cat.E_RM:half_up
, since that is the most commonly used method of rounding.
sys.Core.Cat.E_TK
A Cat.E_TK
(type kind) is an enumeration consisting of the 7 values Cat.E_TK:special
(mainly for system-defined implicit supertypes), Cat.E_TK:scalar
, Cat.E_TK:tuple
, Cat.E_TK:relation
, Cat.E_TK:quasi_tuple
, Cat.E_TK:quasi_relation
, Cat.E_TK:remnant
.
sys.Core.Cat.E_TDM
A Cat.E_TDM
(type definition method) is an enumeration consisting of the 9 values Cat.E_TDM:special
(for some system-defined types that don't best fit in other categories, and all parameterized types; users can not define the latter for now), Cat.E_TDM:root
(complete root type defined in terms of explicit attribute collection; all are fully defined, not parameterized), Cat.E_TDM:restriction
(defined as "explicit other-type where condition"), Cat.E_TDM:alias
(so the same one type can have multiple names), Cat.E_TDM:(union|intersection|exclusion)
(defined as explicit union|intersection|exclusion of other types), Cat.E_TDM:difference
(defined as explicit difference of 2 other types), Cat.E_TDM:negation
(defined as explicit negation of another type).
sys.Core.Cat.E_ENK
A Cat.E_ENK
(expression node kind) is an enumeration consisting of the 10 values Cat.E_ENK:default
(default value of expression's declared type), Cat.E_ENK:(scalar|tuple|relation|quasi_tuple|quasi_relation)
(hard-coded literal scalar|tuple|relation|quasi-tuple|quasi-relation value), Cat.E_ENK:param
(value of expression-containing function parameter), Cat.E_ENK:upd_param
(on-entry value of expression-containing update operator subject-to-update parameter), Cat.E_ENK:ro_param
(value of expression-containing update operator read-only parameter), Cat.E_ENK:func
(result of function invocation, or inlining of function body). Note that only upd_param
and func
(over upd_param
) can be used for a subject-to-update argument of an update operator, but all of these can be used elsewhere. Its default value is Cat.E_ENK:scalar
.
sys.Core.Cat.E_PSAK
A Cat.E_PSAK
(procedural statement argument kind) is an enumeration consisting of the 5 values Cat.E_PSAK:default
(default value of argument's declared type), Cat.E_PSAK:upd_param
(current value of statement-containing procedure subject-to-update parameter), Cat.E_PSAK:ro_param
(value of statement-containing procedure read-only parameter), Cat.E_PSAK:inner_var
(current value of statement-containing procedure lexical variable, not param), Cat.E_PSAK:outer_var
(current value of a non-lexical variable). Note that only upd_param
and (inner|outer)_var
can be used for a subject-to-update argument, but all of these can be used with a read-only argument. Its default value is Cat.E_PSAK:ro_param
.
SYSTEM-DEFINED CORE CATALOG TUPLE DATA TYPES
These tuple data types, essentially all of the system-defined tuple types are special-purpose in nature and are intended for use in defining or working with the system catalog. They are all completely defined types.
Note that many of these types might conceptually have name
attributes, but those would actually be provided by any larger types in which they are embedded, rather than by these types themselves.
Note that whenever an attribute of one of these types isn't significant, given the context (determined by other attributes of the same type), and should be ignored, its value is the default for its type.
To keep things simpler for now, most constraint definitions for these types are missing, or just defined informally.
sys.Core.Cat.RatRoundRule
A Cat.RatRoundRule
is a Tuple
. It specifies a controlled (and typically degrading) coercion of a real number into a rational number having a specific radix and precision. It is mainly used to deterministically massage an operation, whose conceptual result is generally an irrational number, so that its actual result is a best approximating rational number. It is also used to define a generic rounding operation on a rational number that derives a typically less precise rational. A Cat.RatRoundRule
has these 3 attributes: radix
(a PInt2_N
), max_denom
(a PInt
), and round_meth
(a Cat.E_RM
). The rational resulting from the operation is as close as possible to the conceptual result but that its denominator is a non-negative power of radix
and said denominator is not larger than max_denom
; if rounding is needed, then round
dictates the rounding method. The default value of Cat.RatRoundRule
specifies a coersion to a whole number using the Cat.E_RM:half_up
rounding method (its radix is 2 and its max denom is 1).
sys.Core.Cat.Type
A Cat.Type
is a Tuple
. It defines a data type, which can either be (sometimes) invoked directly for values, or be invoked by or embedded into other type definitions. Cat.Type
is used in the catalogs for defining both system and user types (just the interfaces in the former case).
TODO: The catalog types for type definitions need an overhaul.
A Cat.Type
has these 7 attributes:
tk
-Cat.E_TK
-
This broadly declares what kind of type this is (eg, scalar|tuple|relation); it partially says how to interpret the rest of the attributes and/or which of them have significant values.
tdm
-Cat.E_TDM
-
This is the type definition method for the type; it partially says how to interpret the rest of the attributes and/or which of them have significant values. If
tk
isCat.E_TK:special
, thentdm
must beCat.E_TDM:special
;tdm
can be special at other times too. types
-Cat.SetOfNameChain
-
For some values of
tdm
, the data type is defined at least partially in terms of other data types not by way of attribute definitions, and thentypes
lists all/most of those types. Ifftdm
isCat.E_TDM:alias
, then the data type is just a symbolic reference for some other data type (as far as the type system is concerned, they are the same data type, invokable by an extra name), andtypes
has one element that is the name of that type. Ifftdm
isCat.E_TDM:restriction
, then the data type is defined as an explicit subtype of another type by way of an explicit further type constraint applied to it, andtypes
has one element that is the name of that supertype. Ifftdm
isCat.E_TDM:(union|intersection|exclusion)
, then the data type is defined as an explicit union|intersection|exclusion of N other types, andtypes
lists their names, one per element; 2+ elements is the norm; just 1 element means that the data type is a simple alias for the named element; zero elements means the data type is a simple alias for, respectively, the typeEmpty
,Universal
, orEmpty
. Ifftdm
isCat.E_TDM.difference
, then the data type is defined as the difference of 2 other types, andtypes
has one element that is the name of the minuend type. Ifftdm
isCat.E_TDM.negation
, then the data type is defined as the negation of some other type, andtypes
has one element that is the name of that type. subtr_type
-Cat.NameChain
-
Iff
tdm
isCat.E_TDM.difference
, then the data type is defined as the difference of 2 other types, andsubtr_type
is the name of the subtrahend type. attrs
-Cat.NameTypeMap
-
Iff
tdm
isCat.E_TDM:root
, then the data type is defined fundamentally in terms of an explicit attribute collection, andattrs
defines the names and declared types of those attributes. Iff additionallytk
isCat.E_TK:scalar
, thenattrs
specifically defines the attributes of just the core/initial/only possrep; otherwise,attrs
defines the heading of the tuple or relation etc type. It is valid to have zero attributes; in this case, the type consists of exactly one value. keys
-Cat.SetOfSetOfName
-
Iff
tk
isCat.E_TK:(relation|quasi_relation)
andtdm
is notCat.E_TDM:special
, then the data type is or resembles a relation type and can have explicit keys (duality of unique key constraints and terser unique identifiers for the q/relation's member q/tuples) defined over its attributes, andkeys
defines those keys in the canonical simplest form (in contrast with usingconstraint
instead). Each element ofkeys
defines one key of the q/relation, and that element is a set of the attribute names comprising that key. For q/relation types, if no keys are explicitly defined, then it implicitly has a single key comprising all of its attributes. If any explicit keys are defined, then every one must be over a distinct proper subset of the type's attributes, and moreover no key's attributes may be a proper subset of any other key's attributes; if 2 such candidates appear, just use the one that has the subset. It is valid for a key to consist of zero attributes; in this case, that key is the only key of the q/relation type, and values of the type may each consist of no more than one tuple. constraint
-Cat.TypeConstraint
... default one always res True-
Iff
tdm
isCat.E_TDM:root
, then the data type is defined fundamentally in terms of an explicit attribute collection, andconstraint
defines/names a generalized type constraint that validates the collection as a whole. Ifftdm
isCat.E_TDM:restriction
, then the data type is defined as an explicit subtype of another type by way of an explicit further type constraint applied to it, andconstraint
defines/names that further constraint.
The default value of Cat.Type
is an alias of Empty
.
sys.Core.Cat.ExprNode
A Cat.ExprNode
is a Tuple
. It specifies a named expression node, which is the majority component of functional Muldis D code. All arbitrarily complex Muldis D expression trees, including relational queries, are composed of just Cat.ExprNode
, either directly, or indirectly by way of function invocations, as each function body is itself composed entirely of a single expression tree (of at least 1 node). Only functions and update operators may contain Cat.ExprNode
, so for any procedures that would conceptually include them, those portions of the procedures need to be separated out and encapsulated by named functions or inner-functions or update operators or inner-update-operators. Note that, while the general case has expression trees simply denoting a value, in some cases they may instead define a pseudo-variable / virtual variable; that only happens in update operators where the expression is used as an argument for a subject-to-update parameter of an update operator call; in that case the leaf nodes / only node of the expression must map to a subject-to-update parameter of the containing update operator.
A Cat.ExprNode
has these 9 attributes:
name
-Cat.Name
-
This is the declared name of the expression node; other Muldis D code that is composing this expression node into their own definitions would reference it with this name.
tk
-Cat.E_TK
-
This is semi-redundant with
type
(further below); it says whether the declared result data type of the expression node is a scalar|tuple|relation|etc type; it assists in static analysis of Muldis D code in more constrained environments where user-defined type definitions can't or shouldn't be looked up, that is, it allows more static analysis of a function in isolation of where the function would live. type
-Cat.NameChain
-
This is the declared result data type of the expression node. If the expression node represents a literal value, this is often necessary for properly interpreting the details of that literal, particularly for literals that are not scalar. Otherwise, although the result type of an expression can sometimes be inferred from context, such as from the result type of a function it is an invocation of, this redundancy helps make static analysis of Muldis D code easier, so it is easier to validate and optimize in isolation from the other routines it interacts with. Moreover, this type declaration provides a terse way to use the
treat
function frequently in code, so that the programmer and compiler knows that some generic routines are actually supposed to be resulting in a subtype of their normal result types. kind
-Cat.E_ENK
-
This is the declared kind of expression that this node is; it says how to interpret the rest of the attributes and/or which of them have significant values.
scal_lit
-Cat.ScalarLiteral
-
Iff
kind
isCat.E_ENK:scalar
, then the expression represents a hard-coded scalar literal of one of a certain collection of system-defined core scalar types (or subtype thereof), and this is that literal value. coll_lit
-Cat.SetOfNameExprMap
-
Iff
kind
isCat.E_ENK:(|quasi_)(tuple|relation)
, then the expression represents a collection literal, and these are the values of its components. Each element defines one tuple, and each sub-element of that element defines one attribute value for one tuple, with the sub-elementname
matching the attribute name, and the sub-elementexpr
naming another localCat.ExprNode
which defines the value. The value ofcoll_lit
defines exactly one tuple whenkind
specifies a tuple or quasi-tuple, and it defines 0..N tuples whenkind
specifies a relation or quasi-relation. param
-Cat.Name
-
Iff
kind
isCat.E_ENK:param
, then the expression represents the value of the containing function's parameter which this names. Or, ifkind
isCat.E_ENK:upd_param
orCat.E_ENK:ro_param
, then the expression represents the on-entry value or value of the containing update operator's subject-to-update or read-only parameter, respectively. func
-Cat.NameChain
-
Iff
kind
isCat.E_ENK:func
, then the expression represents the result of invoking a named function with specific arguments, and this the name of that function. func_args
-Cat.NameExprMap
-
Iff
func
is used, then these are the arguments for the function invocation. Each element defines one argument value, with the elementname
matching the parameter name, and the elementexpr
naming another localExprNode
which defines the value.
The default value of Cat.ExprNode
represents the literal scalar value Bool:false
.
sys.Core.Cat.InnerFunc
A Cat.InnerFunc
is a Tuple
. It specifies a named inner_function
routine, which is the main component type of a complete routine; a complete function consists of at least one inner function, which is its main body, plus more when it would conceptually be using anonymous inline function definitions (to pass to function-valued function arguments), or when it would conceptually have self-referencing/cyclic expressions.
A Cat.InnerFunc
has these 5 attributes:
name
-Cat.Name
-
This is the declared name of the inner function within its parent complete function; other Muldis D code within said complete function would reference it with this name.
is_recursive
-Bool
-
This is
Bool:true
if the inner function might possibly invoke itself, either directly or indirectly; it isBool:false
if it promises to never be recursive. Note that theis_recursive
attribute does not make any claims regarding the actions of any anonymous functions that it is passed as function-valued arguments, which may cause this inner function to be involved in a recursion even ifis_recursive
isBool:false
. Note that this may be changed later, or the attribute simply be eliminated. params
-Cat.NameTypeMap
-
This is the declared parameter list of the inner function, which has 0..N named and typed parameters.
root_expr
-Cat.Name
-
This indicates which of the expression nodes comprising this inner function is its root node, the result of which is the result of the inner function.
expr
-Cat.ExprTree
-
This defines the entire body of the inner function, which is composed of a single expression tree. This expression tree must reference all of the parameters that the inner function has.
The default value of Cat.InnerFunc
unconditionally results in the literal scalar value Bool:false
.
sys.Core.Cat.Func
A Cat.Func
is a Tuple
. It specifies a named function
routine, which is conceptually a non-anonymous function that is generally invokable by the public (unless its parent package says otherwise).
A Cat.Func
has these 3 attributes:
name
-Cat.Name
-
This is the declared name of the function; other Muldis D code would reference it with this name.
root_inner_func
-Cat.Name
-
This indicates which of the inner functions comprising this function defines its public interface / parameter list and main body.
inner_funcs
-Cat.InnerFuncTree
-
This defines the entire body of the function (both its main body plus any conceptually expression-inlined anonymous functions), which is composed of one or more inner functions, plus its public interface / parameter list, which is defined by one of those.
The default value of Cat.Func
unconditionally results in the literal scalar value Bool:false
as per the default of Cat.InnerFunc
.
sys.Core.Cat.UpdateStmt
A Cat.UpdateStmt
is a Tuple
. It specifies a single update statement (of 1..N variables), which is the most fundamental component of procedural Muldis D code, and is what the body of an update operator routine is composed of. The variables being updated are accessed via the host routine's subject-to-update parameters. All arbitrarily complex Muldis D value assignments, including relational assignments, are composed of just Cat.UpdateStmt
, either directly, or indirectly by way of update operator invocations, as each update operator body is itself composed entirely of 1 or more update statements (grouped as 1 multi-update). Only update operators may contain Cat.UpdateStmt
, so for any procedures that would conceptually include them, those portions of the procedures need to be separated out and encapsulated by named update operators or inner-update-operators.
A Cat.UpdateStmt
has these 3 attributes:
update_oper
-Cat.NameChain
-
Every update statement is an invocation of some other update operator (or inner-update-operator), either a user-defined or system-defined one (the latter generally being the end of the call chain); this is the name of that update operator.
upd_args
-Cat.NameExprMap
-
These are the 1..N subject-to-update arguments to the update operator invocation, as-per
ro_args
. But since each expression tree inupd_args
is binding to a subject-to-update parameter, the expression tree actually is defining a pseudo-variable / virtual-variable over 1..N containing routine subject-to-update parameters; in the most trivial (and common) case, such an expression tree is a single node that represents said parameter without any indirection at all. ro_args
-Cat.NameExprMap
-
These are the 0..N read-only arguments to the update operator invocation. Each element defines one argument value, with the element
name
matching the parameter name, and the elementexpr
naming a localExprNode
which defines the value.
The default value of Cat.UpdateStmt
will unconditionally update 1 subject-to-update parameter of name $topic
with the value Bool:false
.
sys.Core.Cat.InnerUpdateOper
A Cat.InnerUpdateOper
is a Tuple
. It specifies a named update_operator
routine, which is the main component type of a complete implicitly atomic procedural routine; a complete update operator consists of at least one inner update operator, which is its main body, likely plus more when it would conceptually be code refactored.
A Cat.InnerUpdateOper
has these 6 attributes:
name
-Cat.Name
-
This is the declared name of the inner update operator within its parent complete update operator; other Muldis D code within said complete update operator would reference it with this name.
is_recursive
-Bool
-
This is
Bool:true
if the inner update operator might possibly invoke itself, either directly or indirectly; it isBool:false
if it promises to never be recursive. Note that this attribute may be eliminated. upd_params
-Cat.NameTypeMap
-
This is the declared subject-to-update parameter list of the inner update operator, which has 1..N named and typed such parameters. It must have at least 1 element.
ro_params
-Cat.NameTypeMap
-
This is the declared read-only parameter list of the inner update operator, which has 0..N named and typed such parameters. There is a distributed (unique) key over the
name
attributes ofupd_params
andro_params
. exprs
-Cat.ExprSet
-
This defines the expression trees that are arguments to the update operators that
stmt
invokes. These expression trees must reference all of the parameters that the inner update operator has. stmt
-Cat.MultiUpdateStmt
-
This defines the entire body of the inner update operator, which is composed of a single multi-update statement. This multi-update statement must reference all of the parameters that the inner update operator has.
The default value of Cat.InnerUpdateOper
has 1 subject-to-update parameter named $topic
and declared type Bool
and will unconditionally update it to the value Bool:false
; it has zero read-only parameters.
sys.Core.Cat.UpdateOper
A Cat.UpdateOper
is a Tuple
. It specifies a named update operator
routine, which is conceptually a non-anonymous update operator that is generally invokable by the public (unless its parent package says otherwise).
A Cat.UpdateOper
has these 4 attributes:
name
-Cat.Name
-
This is the declared name of the update operator; other Muldis D code would reference it with this name.
root_inner_update_oper
-Cat.Name
-
This indicates which of the inner update operators comprising this update operator defines its public interface / parameter list and main body.
inner_update_opers
-Cat.InnerUpdateOperTree
-
This (save for
inner_funcs
) defines the entire body of the update operator, which is composed of one or more inner update operators, plus its public interface / parameter list, which is defined by one of those. inner_funcs
-Cat.InnerFuncSet
-
This also contributes to the body of the update operator.
The default value of Cat.UpdateOper
is as per the default of Cat.InnerUpdateOper
.
sys.Core.Cat.ProcStmtArg
A Cat.ProcStmtArg
is a Tuple
. It specifies a named argument for a procedural routine invocation done as a procedure statement, and is composed into the Cat.ProcStmt
definition of said statement.
A Cat.ProcStmtArg
has these 7 attributes:
name
-Cat.Name
-
This is the declared name of the invoked procedural routine's parameter (either subject-to-update or read-only) that this argument is binding to.
tk
-Cat.E_TK
-
This is as per the
tk
attribute of aCat.ExprNode
, but applying to the declared data type of the argument. type
-Cat.NameChain
-
This is as per the
type
attribute of aCat.ExprNode
, but applying to the declared data type of the argument. kind
-Cat.E_PSAK
-
This is the declared kind of value that this argument is; it says how to interpret the rest of the attributes and/or which of them have significant values.
param
-Cat.Name
-
Iff
kind
isCat.E_PSAK:upd_param
orCat.E_PSAK:ro_param
, then the argument is the current value or value of the containing procedure's subject-to-update or read-only parameter, respectively. inner_var
-Cat.Name
-
Iff
kind
isCat.E_PSAK:inner_var
, then the argument is the current value of a lexical variable that isn't a parameter. outer_var
-Cat.NameChain
-
Iff
kind
isCat.E_PSAK:outer_var
, then the argument is the current value of a non-lexical variable.
The default value of Cat.ProcStmtArg
will bind to a read-only parameter of name $topic
with a value of the containing procedure's read-only parameter named $topic
.
sys.Core.Cat.ProcStmt
A Cat.ProcStmt
is a Tuple
. It specifies a generic statement from which non-implicitly-atomic procedural Muldis D code is composed. Only procedures (or inner procedures) may contain Cat.ProcStmt
.
A Cat.ProcStmt
has these 3 attributes:
proc
-Cat.NameChain
-
Every procedure statement is an invocation of some other procedural routine (eg, procedure, update operator, system service), either user-defined or system-defined; this is the name of that routine.
upd_args
-Cat.ProcStmtArgSet
-
These are the 0..N subject-to-update arguments to the routine invocation, as-per
ro_args
. ro_args
-Cat.ProcStmtArgSet
-
These are the 0..N read-only arguments to the routine invocation. There is a distributed (unique) key over the
name
attributes ofupd_params
andro_params
.
The default value of Cat.ProcStmt
will invoke sys.Core.Universal.assign
, giving it arguments from same-named and typed parameters.
sys.Core.Cat.InnerProc
A Cat.InnerProc
is a Tuple
. It specifies a named procedure
routine, which is the main component type of a complete procedure; a complete procedure consists of at least one inner procedure, which is its main body, likely plus more when it would conceptually be code refactored.
A Cat.InnerProc
has these 6 attributes:
name
-Cat.Name
-
This is the declared name of the inner procedure within its parent complete procedure; other Muldis D code within said complete procedure would reference it with this name.
is_recursive
-Bool
-
This is
Bool:true
if the inner procedure might possibly invoke itself, either directly or indirectly; it isBool:false
if it promises to never be recursive. Note that this attribute may be eliminated. upd_params
-Cat.NameTypeMap
-
This is the declared subject-to-update parameter list of the inner procedure, which has 0..N named and typed such parameters.
ro_params
-Cat.NameTypeMap
-
This is the declared read-only parameter list of the inner procedure, which has 0..N named and typed such parameters. There is a distributed (unique) key over the
name
attributes ofupd_params
andro_params
. vars
-Cat.NameTypeMap
-
This defines the 0..N (non-parameter) lexical variables of the inner procedure; they initialize to the default values of their declared types.
stmts
-Cat.SeqOfProcStmt
-
This defines the entire main body of the inner procedure, which is composed of 0..N procedure statements. These statements must reference all of the parameters and lexical variables that the inner procedure has.
The default value of Cat.InnerProc
is a no-op; its name
has the default value of Cat.Name
, it has zero parameters, zero variables, and zero statements.
sys.Core.Cat.Proc
A Cat.Proc
is a Tuple
. It specifies a named procedure
routine, which is conceptually a non-anonymous procedure that is generally invokable by the public (unless its parent package says otherwise).
A Cat.Proc
has these 5 attributes:
name
-Cat.Name
-
This is the declared name of the procedure; other Muldis D code would reference it with this name.
root_inner_proc
-Cat.Name
-
This indicates which of the inner procedures comprising this update operator defines its public interface / parameter list and main body.
inner_procs
-Cat.InnerProcTree
-
This (save for
inner_update_opers
andinner_funcs
) defines the entire body of the procedure, which is composed of one or more inner procedures, plus its public interface / parameter list, which is defined by one of those. inner_update_opers
-Cat.InnerUpdateOperTree
-
This also contributes to the body of the update operator.
inner_funcs
-Cat.InnerFuncSet
-
This also contributes to the body of the update operator.
The default value of Cat.Proc
is as per the default of Cat.InnerProc
.
sys.Core.Cat.Exception
TODO.
SYSTEM-DEFINED CORE CATALOG RELATION DATA TYPES
These relation data types, essentially all of the system-defined relation types are special-purpose in nature and are intended for use in defining or working with the system catalog. They are all completely defined types.
To keep things simpler for now, most constraint definitions for these types are missing, or just defined informally.
sys.Core.Cat.NameTypeMap
A Cat.NameTypeMap
is a Relation
. It defines a basic component list, meaning a set of names, with a declared data type name for each. It forms the foundation for most componentized type definitions, including all tuple and relation types (for which it is named heading), and it is used also for the components list of a scalar possrep. It is also used to define parameter lists for routines. A Cat.NameTypeMap
has 2 attributes, name
(a Cat.Name
) and type
(a Cat.NameChain
); the name
is the declared name of the attribute or parameter, and comprises a unary key; the type
is the declared data type of the attribute or parameter. Its default value has zero tuples.
sys.Core.Cat.NameExprMap
A Cat.NameExprMap
is a Relation
. It defines a basic component-values list, meaning a set of names, with a declared local expression node name for each. It is used to define collection literals; one Cat.NameExprMap
defines a whole Tuple
value. It is also used to define argument lists for routine invocations. A Cat.NameExprMap
has 2 attributes, name
and expr
, each of those being a Cat.Name
; the name
is the name of the tuple/etc attribute or routine argument, and comprises a unary key; the expr
is the declared local name of the expression node which defines the value for the attribute or argument. Its default value has zero tuples.
sys.Core.Cat.AttrRenameMap
A Cat.AttrRenameMap
is a Relation
. It is used as a specification for how to rename attributes of some collection. A Cat.AttrRenameMap
has 2 attributes, before
and after
, each of those being a Cat.Name
, and each of those being a unary key. Its default value has zero tuples.
sys.Core.Cat.ExprSet
A Cat.ExprSet
is the same as a Cat.ExprTree
except that it can represent multiple trees rather than one; this is realized in that more than one (rather than exactly one) member may have none of its peers as a parent node. It so happens then that Cat.ExprTree
is a proper subtype of Cat.ExprSet
.
sys.Core.Cat.ExprTree
A Cat.ExprTree
is a Relation
with the same heading as Cat.ExprNode
; it specifies a simple tree of named expression nodes, which are its tuples. It has a unary (unique) key on the name
attribute, and it must have at least 1 member tuple. All member tuples must define a simple expression node tree, such that every member except one has one of its peers as a parent node, and no direct cycles between members are permitted (only indirect cycles based on function / inner-function invocations are allowed). The default value of Cat.ExprTree
has one tuple that is the default value of Cat.ExprNode
; the tree represents the literal scalar value Bool:false
.
sys.Core.Cat.InnerFuncSet
A Cat.InnerFuncSet
is a Relation
with the same heading as Cat.InnerFunc
; it specifies a set of inner functions (that comprise parts of the same complete routine), which are its tuples. It has a unary (unique) key on the name
attribute. Its default value is empty, which may be applicable if the complete routine is not a function.
sys.Core.Cat.InnerFuncTree
A Cat.InnerFuncTree
is a proper subtype of Cat.InnerFuncSet
which is likely to only be applicable if the complete routine is a function. It must have at least 1 member tuple. All member tuples must define a single invocation tree but that cycles are allowed, including that invoke what is conceptually the tree root (main function if applicable). The default value of Cat.InnerFuncTree
has one tuple that is the default value of Cat.InnerFunc
.
sys.Core.Cat.MultiUpdateStmt
A Cat.MultiUpdateStmt
is a Relation
with the same heading as Cat.UpdateStmt
; it is a multi-update statement, which is the narrowest scope implicitly atomic component of procedural Muldis D code. One value of this type comprises the entire body of an update operator (or inner-update-operator). It must have at least 1 member tuple. The default value of Cat.MultiUpdateStmt
has one tuple that is the default value of Cat.UpdateStmt
.
sys.Core.Cat.InnerUpdateOperSet
A Cat.InnerUpdateOperSet
is a Relation
with the same heading as Cat.InnerUpdateOper
; it specifies a set of inner update operators (that comprise parts of the same complete routine), which are its tuples. It has a unary (unique) key on the name
attribute. Its default value is empty, which may be applicable if the complete routine is not an update operator.
sys.Core.Cat.InnerUpdateOperTree
A Cat.InnerUpdateOperTree
is a proper subtype of Cat.InnerUpdateOperSet
which is likely to only be applicable if the complete routine is a update operator. It must have at least 1 member tuple. All member tuples must define a single invocation tree but that cycles are allowed, including that invoke what is conceptually the tree root (main update operator if applicable). The default value of Cat.InnerUpdateOperTree
has one tuple that is the default value of Cat.InnerUpdateOper
.
sys.Core.Cat.ProcStmtArgSet
A Cat.ProcStmtArgSet
is a Relation
with the same heading as Cat.ProcStmtArg
; it specifies a set of arguments to an invocation of a procedural routine. It has a unary (unique) key on the name
attribute. Its default value is empty.
sys.Core.Cat.InnerProcTree
A Cat.InnerProcTree
is to Cat.InnerProc
what Cat.InnerUpdateOperTree
is to Cat.InnerUpdateOper
.
sys.Core.Cat.SetOfName
A Cat.SetOfName
is a Set
whose value
attribute has a declared type of Cat.Name
.
sys.Core.Cat.SetOfSetOfName
A Cat.SetOfSetOfName
is a Set
whose value
attribute has a declared type of Cat.SetOfName
.
sys.Core.Cat.SetOfNameExprMap
A Cat.SetOfNameExprMap
is a Set
whose value
attribute has a declared type of Cat.NameExprMap
.
sys.Core.Cat.SetOfNameChain
A Cat.SetOfNameChain
is a Set
whose value
attribute has a declared type of Cat.NameChain
.
sys.Core.Cat.NESeqOfName
A Cat.NESeqOfName
is a Seq
whose value
attribute has a declared type of Cat.Name
and that must have at least 1 element; this type is used as the definition of the sequence possrep of a Cat.NameChain
(see that type for details).
sys.Core.Cat.SeqOfProcStmt
A Cat.SeqOfProcStmt
is a Seq
whose value
attribute has a declared type of Cat.ProcStmt
.
SYSTEM-DEFINED CORE SPECIALIZED SUBTYPES
These types are proper subtypes of other core types, and they are system-defined for convenience, as they are anticipated to be frequently used; in fact, most of them are used as the declared parameter types of various core operators.
sys.Core.Spec.PInt1_4
-
A
PInt1_4
is a proper subtype ofPInt
where all member values are between 1 and 4. Its maximum value is 4. The cardinality of this type is 4.
sys.Core.Spec.PInt2_N
A PInt2_N
is a proper subtype of PInt
where all member values are greater than 1. Its default and minimum value is 2.
sys.Core.Spec.PInt2_36
-
A
PInt2_36
is a proper subtype ofPInt2_N
where all member values are between 2 and 36. (The significance of the number 36 is 10 digits plus 26 letters.) Its maximum value is 36. The cardinality of this type is 35. sys.Core.Spec.(Set|Maybe|Seq|Bag)Of(Bool|Int|Rat|Blob|Text)
-
A
(Set|Maybe|Seq|Bag)Of(Bool|Int|Rat|Blob|Text)
is a completely defined proper subtype of(Set|Maybe|Seq|Bag)
whosevalue
attribute has a declared type of a(Bool|Int|Rat|Blob|Text)
subtype. sys.Core.Spec.(Set|Bag)OfRelation
-
A
(Set|Bag)OfRelation
is an incompletely defined proper subtype ofSet|Bag
whosevalue
attribute has a declared type of aRelation
subtype. sys.Core.Spec.QuasiSetOfRelation
-
A
QuasiSetOfRelation
is an incompletely defined proper subtype ofQuasiSet
whosevalue
attribute has a declared type ofRelation
; this is the parameter type of the N-ary relationaljoin
operator.
SYSTEM-DEFINED GENERIC UNIVERSAL FUNCTIONS
These functions are applicable to values of any data type at all.
sys.Core.Universal.is_equal of Bool (Some.Universal $v1, Some.Universal $v2)
-
This function results in
Bool:true
iff its 2 arguments are exactly the same value, andBool:false
otherwise. This function's arguments must be of compatible declared types; in this case, 2 declared types are compatible iff at least one of the following is true: 1. they are both subtypes of a common scalar root type; 2. they are both subtypes of a common non-incomplete tuple or relation type, that is they essentially have the same headings; 3. at least one type is a generic (eg-Universal
) or incomplete (eg-Seq
) type, and it is a supertype of the other. This function is commutative. sys.Core.Universal.is_not_equal of Bool (Some.Universal $v1, Some.Universal $v2)
-
This function is exactly the same as
sys.Core.Universal.is_equal
except that it results in the opposite boolean value when given the same arguments. sys.Core.Universal.is_value_of_type of Bool (Cat.NameChain $type, Universal $v)
-
This function results in
Bool:true
iff the value of its$v
argument is a member of the data type whose name is given in the$type
argument, andBool:false
otherwise. As trivial cases, this function always results inBool:true
if the named type isUniversal
, andBool:false
if it isEmpty
. This function will fail if the named type doesn't exist in the virtual machine. sys.Core.Universal.treat of Some.Universal (Cat.NameChain $as, Some.Universal $v)
-
This function results in the value of its
$v
argument, but that the declared type of the result is the not-Empty
data type whose name is given in the$as
argument. This function will fail if the named type doesn't exist in the virtual machine, or if$v
isn't a member of the named type. The purpose oftreat
is to permit taking values from a context having a more generic declared type, and using them in a context having a more specific declared type; such an action would otherwise be blocked at compile time due to a type-mismatch error;treat
causes the type-mismatch validation, and possible failure, to happen at runtime instead, on the actual value rather than declared value. For example, if you are storing anInt
value in aScalar
-typed variable, usingtreat
will cause the compiler to let you use that variable as an argument toInt.sum
, which it otherwise wouldn't. sys.Core.Universal.default of Some.Universal (Cat.NameChain $of)
-
This function results in the default value of the not-
Empty
data type whose name is given in the$of
argument, and the declared type of the result is that same type. This function will fail if the named type doesn't exist in the virtual machine, either at compile or runtime depending whether the type is in the system or user namespace. This function is conceptually implicitly used to provide default values for variables, so they always hold valid values of their declared type.
SYSTEM-DEFINED GENERIC ORDERED FUNCTIONS
These functions are applicable to values of any data type which is a subtype of Ordered
. They provide a common syntax for sort-related functionality, though technically every type having these functions is re-implementing its own version. If values of an ordered data type can conceivably be sorted using multiple criteria (such as different text collations), then these functions just represent the default criteria; any additional criteria are represented by additional functions declared for just the types they apply to.
sys.Core.Ordered.comparison of Order (Some.Ordered $v1, Some.Ordered $v2)
-
This function results in
Order:same
iff its 2 arguments are exactly the same value, and otherwise it results inOrder:increase
if the value of the$v2
argument is considered to be an increase (as defined by the type) over the value of the$v1
argument, and otherwise it results inOrder:decrease
as the reverse of the last condition would be true. This function's arguments must be of compatible declared types; in this case, 2 declared types are compatible iff they are both subtypes of a common scalar type that declares itself anOrdered
subtype. Note thatcomparison
is considered the only fundamental ordered-specific operator, and all others are defined over it. sys.Core.Ordered.reverse_comparison of Order (Some.Ordered $v1, Some.Ordered $v2)
-
This function is exactly the same as
sys.Core.Ordered.comparison
except that it results in the reverse value when given the same arguments. It is a short-hand for applyingsys.Core.Order.reverse
to the result ofsys.Core.Ordered.comparison
with the same arguments. sys.Core.Ordered.is_increase of Bool (Some.Ordered $v1, Some.Ordered $v2)
-
This function results in
Bool:true
iffsys.Core.Ordered.comparison
would result inOrder:increase
when given the same arguments, andBool:false
otherwise. sys.Core.Ordered.is_decrease of Bool (Some.Ordered $v1, Some.Ordered $v2)
-
This function results in
Bool:true
iffsys.Core.Ordered.comparison
would result inOrder:decrease
when given the same arguments, andBool:false
otherwise. sys.Core.Ordered.is_inside_range of Bool (Some.Ordered $topic, Some.Ordered $min, Some.Ordered $max, Bool $min_is_inside, Bool $max_is_inside)
-
This function results in
Bool:true
iff its$topic
argument is within the range whose bounds are defined by its$min
and$max
arguments. If$min_is_inside
or$max_is_inside
areBool:true
, then$topic
is considered to be within the range if it is equal to$min
or$max
, respectively. This function's arguments must be of compatible declared types as persys.Core.Ordered.comparison
. This function will fail if$min
is an increase over$max
. sys.Core.Ordered.is_outside_range of Bool (Some.Ordered $topic, Some.Ordered $min, Some.Ordered $max, Bool $min_is_inside, Bool $max_is_inside)
-
This function is exactly the same as
sys.Core.Ordered.is_inside_range
except that it results in the opposite boolean value when given the same arguments. sys.Core.Ordered.min of Some.Ordered (Set{Some.Ordered} $topic)
-
This function is a reduction operator that recursively takes each pair of its N input element values and picks the minimum of the 2 (a process which is both commutative and associative) until just one is left, which is the function's result. If
$topic
has zero values, thenmin
results in the result type's concept of positive infinity, which is the identity value for min. This function will fail on a$topic
of zero values if the result type's concept of positive infinity is impossible or impractically large to represent, such as with the infiniteText
type. sys.Core.Ordered.max of Some.Ordered (Set{Some.Ordered} $topic)
-
This function is exactly the same as
sys.Core.Ordered.min
except that it results in the maximum input element value rather than the minimum one, and its identity value is the result type's concept of negative infinity. sys.Core.Ordered.maybe_min of Maybe{Some.Ordered} (Set{Some.Ordered} $topic)
-
This function is exactly the same as
sys.Core.Ordered.min
except that it results in aMaybe
of what is otherwise the result type, and that result has zero elements if the argument has zero elements. sys.Core.Ordered.maybe_max of Maybe{Some.Ordered} (Set{Some.Ordered} $topic)
-
This function is to
sys.Core.Ordered.max
assys.Core.Ordered.maybe_min
is tosys.Core.Ordered.min
.
SYSTEM-DEFINED CORE SCALAR FUNCTIONS
These functions are applicable to just one or more specific system-defined core scalar data type.
Functions for sys.Core.Bool.Bool
These functions select values of the Bool
enumeration.
sys.Core.Bool.(false|true) of Bool ()
-
This selector function results in the
Bool:(false|true)
value.
These functions implement commonly used boolean operations.
sys.Core.Bool.not of Bool (Bool $topic)
-
This function results in the logical not of its argument.
sys.Core.Bool.and of Bool (Set{Bool} $topic)
-
This function is a reduction operator that recursively takes each pair of its N input element values and does a logical and (which is both commutative and associative) on them until just one is left, which is the function's result. If
$topic
has zero values, thenand
results inBool:true
, which is the identity value for logical and. sys.Core.Bool.or of Bool (Set{Bool} $topic)
-
This function is a reduction operator that recursively takes each pair of its N input element values and does a logical inclusive-or (which is both commutative and associative) on them until just one is left, which is the function's result. If
$topic
has zero values, thenor
results inBool:false
, which is the identity value for logical inclusive-or. sys.Core.Bool.xor of Bool (Bag{Bool} $topic)
-
This function is a reduction operator that recursively takes each pair of its N input element values and does a logical exclusive-or (which is both commutative and associative) on them until just one is left, which is the function's result. If
$topic
has zero values, thenxor
results inBool:false
, which is the identity value for logical exclusive-or.
Functions for sys.Core.Order.Order
These functions select values of the Order
enumeration.
sys.Core.Order.(increase|same|decrease) of Order ()
-
This selector function results in the
Order:(increase|same|decrease)
value.
These functions implement commonly used order-enumeration operations.
sys.Core.Order.reverse of Order (Order $topic)
-
This function results in the reverse value of its argument; an
Order:increase
orOrder:decrease
argument results in the other one of the two; anOrder:same
argument results in itself.
Functions for sys.Core.Int.Int
These functions implement commonly used integer numeric operations.
sys.Core.Int.increase of Int (Int $topic)
-
This function results in its argument increased by 1.
sys.Core.Int.decrease of Int (Int $topic)
-
This function results in its argument decreased by 1.
sys.Core.Int.abs of UInt (Int $topic)
-
This function results in the absolute value of its argument.
sys.Core.Int.sum of Int (Bag{Int} $addends)
-
This function results in the sum of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and adds (which is both commutative and associative) them together until just one is left, which is the result. If
$addends
has zero values, thensum
results in the integer zero, which is the identity value for addition. sys.Core.Int.difference of Int (Int $minuend, Int $subtrahend)
-
This function results in the difference when its
$subtrahend
argument is subtracted from its$minuend
argument. sys.Core.Int.product of Int (Bag{Int} $factors)
-
This function results in the product of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and multiplies (which is both commutative and associative) them together until just one is left, which is the result. If
$factors
has zero values, thenproduct
results in the integer 1, which is the identity value for multiplication. sys.Core.Int.quotient of Int (Int $dividend, Int $divisor)
-
This function results in the quotient when its
$dividend
argument is divided by its$divisor
argument using integer division. This function will fail if$divisor
is zero. sys.Core.Int.remainder of UInt (Int $dividend, Int $divisor)
-
This function results in the remainder when its
$dividend
argument is divided by its$divisor
argument using integer division. This function will fail if$divisor
is zero. sys.Core.Int.maybe_quotient of Maybe{Int} (Int $dividend, Int $divisor)
-
This function is exactly the same as
sys.Core.Int.quotient
except that it results in aMaybe
of what is otherwise the result, and that result has zero elements if$divisor
is zero. sys.Core.Int.maybe_remainder of Maybe{UInt} (Int $dividend, Int $divisor)
-
This function is exactly the same as
sys.Core.Int.remainder
except that it results in aMaybe
of what is otherwise the result, and that result has zero elements if$divisor
is zero. sys.Core.Int.range of Int (Set{Int} $topic)
-
This function results in the difference between the lowest and highest element values of its argument. If
$topic
has zero values, thenrange
results in the integer zero. sys.Core.Int.median of Set{Int} (Bag{Int} $topic)
-
This function results in the 1 or 2 median values of the N element values of its argument; they are returned as a set. It is equivalent to first arranging the input values from least to greatest, and then taking the single middle value, if the count of input values is odd, or taking the 2 middle values, if the count of input values is even (but if the 2 middle values are the same value, the output has one element). If
$topic
has zero values, then the result set is empty. sys.Core.Int.mode of Set{Int} (Bag{Int} $topic)
-
This function results in the mode of the N element values of its argument; it is the set of values that appear the most often as input elements, and all have the same count of occurrances. As a trivial case, if all input elements have the same count of occurrances, then they will all be in the output. If
$topic
has zero values, then the result set is empty. sys.Core.Int.power of Int (Int $radix, UInt $exponent)
-
This function results in its
$radix
argument taken to the power of its (unsigned integer)$exponent
argument. This function will fail if$radix
and$exponent
are both zero. sys.Core.Int.factorial of PInt (UInt $topic)
-
This function results in the factorial of its argument (it is defined for an argument of zero to result in 1, as per the identity value for multiplication of an empty set).
These functions convert between Int
values and canonically formatted representations of integers as character strings.
sys.Core.Int.Int_from_NEText of Int (NEText $text, PInt2_36 $radix)
-
This selector function results in the
Int
value that its$text
argument maps to when the whole character string is evaluated as a base-$radix
integer. Extending the typical formats of [base-2, base-8, base-10, base-16], this function supports base-2 through base-36; to get the latter, the characters 0-9 and A-Z represent values in 0-35. This function will fail if$text
can't be mapped as specified. sys.Core.Int.NEText_from_Int of NEText (Int $int, PInt2_36 $radix)
-
This selector function results in the
NEText
value where its$int
argument is formatted as a base-$radix
integer.
These functions convert between Int
values and canonically formatted representations of integers as binary strings. Conjecture: These may not actually be useful, and perhaps only operators that take an argument specifying a fixed-length field size, with big and little endian versions, would be appropriate instead. Or maybe both kinds are necessary.
sys.Core.Int.Int_from_Blob_S_VBE of Int (NEBlob $blob)
-
This selector function results in the
Int
value that its$blob
argument maps to when the whole bit string is treated literally as a variable-length binary (two's complement) signed integer of 1 or more bits in length. The first bit is taken as the sign bit, and any other bits provide greater precision than the -1 thru 0 range. The bit string is assumed to be big-endian, since it may not be possible to use little-endian in situations where the bit length isn't a multiple of 8. sys.Core.Int.Blob_S_VBE_from_Int of NEBlob (Int $int)
-
This selector function results in the
Blob
value where its$int
argument is formatted as a variable-length binary (two's complement) signed integer of 1 or more bits in length; the smallest number of bits necessary to store$int
is used. sys.Core.Int.Int_from_Blob_U_VBE of UInt (NEBlob $blob)
-
This function is the same as
sys.Core.Int.Int_from_Blob_S_VBE
but that it does unsigned integers. sys.Core.Int.Blob_U_VBE_from_Int of UInt (NEBlob $blob)
-
This function is the same as
sys.Core.Int.Blob_S_VBE_from_Int
but that it does unsigned integers.
Functions for sys.Core.Rat.Rat
These functions are essentially selectors and attribute extractors for the conceptual possrep of a rational in terms of an integral numerator plus denominator.
sys.Core.Rat.Rat_from_Int_pair of Rat (Int $numerator, PInt $denominator)
-
This selector function results in the
Rat
value that its$numerator
and$denominator
arguments map to when collectively interpreted in the appropriate fashion, as if there were a possrep for theRat
type that was composed of such 2 attributes, but keeping in mind that multiple distinct argument pairs can map to each sameRat
value, since the arguments don't have to be a canonical pair. sys.Core.Rat.numerator of Int (Rat $topic)
-
This function results in the canonical numerator of its argument, which assumes said rational is represented with the pair of smallest possible integers.
sys.Core.Rat.denominator of PInt (Rat $topic)
-
This function results in the canonical denominator of its argument, which assumes said rational is represented with the pair of smallest possible integers.
These functions implement commonly used rational numeric operations.
sys.Core.Rat.abs of URat (Rat $topic)
-
This function results in the absolute value of its argument.
sys.Core.Rat.sum of Rat (Bag{Rat} $addends)
-
This function results in the sum of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and adds (which is both commutative and associative) them together until just one is left, which is the result. If
$addends
has zero values, thensum
results in the rational zero, which is the identity value for addition. sys.Core.Rat.difference of Rat (Rat $minuend, Rat $subtrahend)
-
This function results in the difference when its
$subtrahend
argument is subtracted from its$minuend
argument. sys.Core.Rat.product of Rat (Bag{Rat} $factors)
-
This function results in the product of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and multiplies (which is both commutative and associative) them together until just one is left, which is the result. If
$factors
has zero values, thenproduct
results in the rational 1, which is the identity value for multiplication. sys.Core.Rat.quotient of Rat (Rat $dividend, Rat $divisor)
-
This function results in the quotient when its
$dividend
argument is divided by its$divisor
argument using rational division. This function will fail if$divisor
is zero. sys.Core.Rat.maybe_quotient of Maybe{Rat} (Rat $dividend, Rat $divisor)
-
This function is exactly the same as
sys.Core.Rat.quotient
except that it results in aMaybe
of what is otherwise the result, and that result has zero elements if$divisor
is zero. sys.Core.Rat.range of Rat (Set{Rat} $topic)
-
This function results in the difference between the lowest and highest element values of its argument. If
$topic
has zero values, thenrange
results in the rational zero. sys.Core.Rat.mean of Rat (Bag{Rat} $topic)
-
This function results in the mean or arithmetic average of the N element values of its argument. It is equivalent to first taking the sum of the input values, and dividing that sum by the count of the input values. If
$topic
has zero values, then this function will fail. sys.Core.Rat.maybe_mean of Maybe{Rat} (Bag{Rat} $topic)
-
This function is exactly the same as
sys.Core.Rat.mean
except that it results in aMaybe
of what is otherwise the result, and that result has zero elements if$topic
has zero values. sys.Core.Rat.median of Set{Rat} (Bag{Rat} $topic)
-
This function results in the 1 or 2 median values of the N element values of its argument; they are returned as a set. It is equivalent to first arranging the input values from least to greatest, and then taking the single middle value, if the count of input values is odd, or taking the 2 middle values, if the count of input values is even (but if the 2 middle values are the same value, the output has one element). If
$topic
has zero values, then the result set is empty. sys.Core.Rat.mean_of_median of Rat (Bag{Rat} $topic)
-
This function is a wrapper over
sys.Core.Rat.median
that will result in the mean of its result elements; it will fail if there are zero elements. sys.Core.Rat.mode of Set{Rat} (Bag{Rat} $topic)
-
This function results in the mode of the N element values of its argument; it is the set of values that appear the most often as input elements, and all have the same count of occurrances. As a trivial case, if all input elements have the same count of occurrances, then they will all be in the output. If
$topic
has zero values, then the result set is empty. sys.Core.Rat.round of Rat (Rat $topic, Cat.RatRoundRule $round_rule)
-
This function results in the rational that is equal to or otherwise nearest to its
$topic
argument, where the nearest is determined by the rational rounding rule specified by the$round_rule
argument. sys.Core.Rat.power of PRat (PRat $radix, Rat $exponent)
-
This function results in its (positive rational)
$radix
argument taken to the power of its$exponent
argument. Note that, while this function might conceptually have multiple real number results for some fractional$exponent
, it will always only result in the one that is positive. sys.Core.Rat.log of Rat (PRat $topic, PRat $radix, Cat.RatRoundRule $round_rule)
-
This function results in the logarithm of its
$topic
argument to the base given in its (positive rational)$radix
argument. Since the result would be an irrational number in the general case, the$round_rule
argument specifies how to coerce the conceptual result into a rational number that is the actual result. sys.Core.Rat.natural_power of PRat (Rat $exponent, Cat.RatRoundRule $round_rule)
-
This function results in the special mathematical constant e (which is the base of the natural logarithm) taken to the power of its
$exponent
argument. The$round_rule
parameter is as perlog
. sys.Core.Rat.natural_log of Rat (PRat $topic, Cat.RatRoundRule $round_rule)
-
This function results in the natural logarithm of its
$topic
argument. The$round_rule
parameter is as perlog
.
These functions convert between Rat
values and canonically formatted representations of rationals as character strings.
sys.Core.Rat.Rat_from_NEText of Rat (NEText $text, PInt2_36 $radix)
-
This selector function results in the
Rat
value that its$text
argument maps to when the whole character string is evaluated as a base-$radix
rational. Extending the typical formats of [base-2, base-8, base-10, base-16], this function supports base-2 through base-36; to get the latter, the characters 0-9 and A-Z represent values in 0-35. This function will fail if$text
can't be mapped as specified. sys.Core.Rat.NEText_from_Rat of NEText (Rat $rat, PInt2_36 $radix)
-
This selector function results in the
NEText
value where its$rat
argument is formatted as a base-$radix
rational.
These functions convert between Rat
values and equal or nearly equal Int
values.
sys.Core.Rat.Rat_from_Int of Rat (Int $int)
-
This selector function results in the
Rat
value that is conceptually equal to itsInt
argument. sys.Core.Rat.Int_from_Rat of Int (Rat $rat, Cat.E_RM $round_meth)
-
This selector function results in the
Int
value that is conceptually equal to or otherwise nearest to its$rat
argument, where the nearest is determined by the rounding method specified by the$round_meth
argument.
Functions for sys.Core.Blob.Blob
These functions implement commonly used binary string operations.
sys.Core.Blob.catenation of Blob (Seq{Blob} $topic)
-
This function results in the catenation of the N element values of its argument; it is a reduction operator that recursively takes each consecutive pair of input values and catenates (which is associative) them together until just one is left, which is the result. If
$topic
has zero values, thencatenate
results in the empty string value, which is the identity value for catenate. sys.Core.Blob.repeat of Blob (Blob $topic, UInt $count)
-
This function results in the catenation of
$count
instances of$topic
. sys.Core.Blob.length_in_bits of UInt (Blob $topic)
-
This function results in the length of its argument in bits.
sys.Core.Blob.is_substr of Bool (Blob $look_in, Blob $look_for, Bool $fixed_start, Bool $fixed_end)
-
This function results in
Bool:true
iff its$look_for
argument is a substring of its$look_in
argument as per the optional$fixed_start
and$fixed_end
constraints, andBool:false
otherwise. If$fixed_start
or$fixed_end
areBool:true
, then$look_for
must occur right at the start or end, respectively, of$look_in
in order forcontains
to results inBool:true
; if either flag isBool:false
, its additional constraint doesn't apply. sys.Core.Blob.is_not_substr of Bool (Blob $look_in, Blob $look_for, Bool $fixed_start, Bool $fixed_end)
-
This function is exactly the same as
sys.Core.Blob.is_substr
except that it results in the opposite boolean value when given the same arguments. sys.Core.Blob.not of Blob (Blob $topic)
-
This function results in the bitwise not of its argument.
sys.Core.Blob.and of Blob (Set{Blob} $topic)
-
This function is a reduction operator that recursively takes each pair of its N input element values and does a bitwise and (which is both commutative and associative) on them until just one is left, which is the function's result. This function's argument values must all be of the same length in bits, that length being part of the argument's declared type (that is,
Blob
subtype) definition, and that is also the length in bits of the function's result. If$topic
has zero values, thenand
will result in an appropriate-length string of identity/1 valued bits. sys.Core.Blob.or of Blob (Set{Blob} $topic)
-
This function is the same as
sys.Core.Blob.and
but that it recursively does a bitwise inclusive-or rather than a bitwise and, and its identity value is composed of zero valued bits. sys.Core.Blob.xor of Blob (Bag{Blob} $topic)
-
This function is the same as
sys.Core.Blob.or
but that it recursively does a bitwise exclusive-or rather than a bitwise inclusive-or.
These functions convert between Blob
values and canonically formatted representations of binary strings as character strings.
sys.Core.Blob.Blob_from_Text of Blob (Text $text, PInt1_4 $size)
-
This selector function results in the
Blob
value that its$text
argument maps to when each input character represents a sequence of 1-4 bits, the number of bits per character being determined by the$size
argument; for example, if$size
is 1, then each input character is a [0-1] and represents a bit; or, if$size
is 4, then each input character is a [0-9A-F] and represents 4 bits. This function will fail if$text
can't be mapped as specified. sys.Core.Blob.Text_from_Blob of Text (Blob $blob, PInt1_4 $size)
-
This selector function results in the
Text
value where its argument is encoded using a character for each sequence of 1-4 bits, the number of bits per character being determined by the$size
argument. This function will fail if$blob
doesn't have a length in bits which is a multiple of$size
.
Functions for sys.Core.Text.Text
These functions implement commonly used character string operations.
sys.Core.Text.catenation of Text (Seq{Text} $topic)
-
This function results in the catenation of the N element values of its argument; it is a reduction operator that recursively takes each consecutive pair of input values and catenates (which is associative) them together until just one is left, which is the result. If
$topic
has zero values, thencatenate
results in the empty string value, which is the identity value for catenate. sys.Core.Text.repeat of Text (Text $topic, UInt $count)
-
This function results in the catenation of
$count
instances of$topic
. sys.Core.Text.length_in_nfd_graphs of UInt (Text $topic)
-
This function results in the length of its argument in Unicode Normalization Form D graphemes.
sys.Core.Text.length_in_nfc_graphs of UInt (Text $topic)
-
This function results in the length of its argument in Unicode Normalization Form C graphemes.
sys.Core.Text.length_in_nfd_codes of UInt (Text $topic)
-
This function results in the length of its argument in Unicode Normalization Form D code points.
sys.Core.Text.length_in_nfc_codes of UInt (Text $topic)
-
This function results in the length of its argument in Unicode Normalization Form C code points.
sys.Core.Text.is_substr of Bool (Text $look_in, Text $look_for, Bool $fixed_start, Bool $fixed_end)
-
This function results in
Bool:true
iff its$look_for
argument is a substring of its$look_in
argument as per the optional$fixed_start
and$fixed_end
constraints, andBool:false
otherwise. If$fixed_start
or$fixed_end
areBool:true
, then$look_for
must occur right at the start or end, respectively, of$look_in
in order forcontains
to result inBool:true
; if either flag isBool:false
, its additional constraint doesn't apply. sys.Core.Text.is_not_substr of Bool (Text $look_in, Text $look_for, Bool $fixed_start, Bool $fixed_end)
-
This function is exactly the same as
sys.Core.Text.is_substr
except that it results in the opposite boolean value when given the same arguments. sys.Core.Text.case_folded_to_upper (Text $topic)
-
This function results in the transformation of its argument where any letters considered to be (small) lowercase are folded to (capital) uppercase.
sys.Core.Text.case_folded_to_lower (Text $topic)
-
This function results in the transformation of its argument where any letters considered to be (capital) uppercase are folded to (small) lowercase.
sys.Core.Text.whitespace_trimmed (Text $topic)
-
This function results in the value of its argument but that any leading or trailing whitespace characters are trimmed.
SYSTEM-DEFINED CORE GENERIC NONSCALAR FUNCTIONS
These functions are applicable to mainly nonscalar types, but are generic in that they typically work with any nonscalar types.
Functions for sys.Core.Tuple.Tuple Having Single Input Tuples
sys.Core.Tuple.degree of UInt (Tuple $topic)
-
This function results in the degree of its argument (that is, the count of attributes it has).
sys.Core.Tuple.attr_from_Tuple of Some.ScaTupRel (Tuple $topic)
-
This function results in the scalar or nonscalar value of the sole attribute of its argument. This function will fail if its argument is not of degree 1.
sys.Core.Tuple.Tuple_from_attr of Tuple (Cat.Name $name, Some.ScaTupRel $value)
-
This function results in the
Tuple
value which has just one attribute whose name is given by$name
and whose value is given by$value
; the attribute's declared type is the same as that of$value
. sys.Core.Tuple.attr of Some.ScaTupRel (Tuple $topic, Cat.Name $name)
-
This function results in the scalar or nonscalar value of the attribute of
$topic
whose name is given by$name
. This function will fail if$name
specifies an attribute name that$topic
doesn't have. sys.Core.Tuple.update_attr of Tuple (Tuple $topic, Cat.Name $name, Some.ScaTupRel $value)
-
This function results in its
$topic
argument but that its attribute whose name is$name
has been updated with a new scalar or nonscalar value given by$value
. This function will fail if$name
specifies an attribute name that$topic
doesn't have, or if the declared type of$value
isn't a subtype of the declared type of the attribute. sys.Core.Tuple.rename of Tuple (Tuple $topic, Cat.AttrRenameMap $map)
-
This function results in a
Tuple
value that is the same as its$topic
argument but that some of its attributes have different names. Each tuple of the argument$map
specifies how to rename one$topic
attribute, with thebefore
andafter
attributes of a$map
tuple representing the old and new names of a$topic
attribute, respectively. As a trivial case, this function's result is$topic
if$map
has no tuples. This function supports renaming attributes to each others' names. This function will fail if$map
specifies any old names that$topic
doesn't have, or any new names that are the same as$topic
attributes that aren't being renamed. sys.Core.Tuple.projection of Tuple (Tuple $topic, Cat.SetOfName $attrs)
-
This function results in the projection of its
$topic
argument that has just the subset of attributes of$topic
which are named in its$attrs
argument. As a trivial case, this function's result is$topic
if$attrs
lists all attributes of$topic
; or, it is the nullary tuple if$attrs
is empty. This function will fail if$attrs
specifies any attribute names that$topic
doesn't have. sys.Core.Tuple.cmpl_projection of Tuple (Tuple $topic, Cat.SetOfName $attrs)
-
This function is the same as
projection
but that it results in the complementary subset of attributes of$topic
when given the same arguments. sys.Core.Tuple.wrap of Tuple (Tuple $topic, Cat.SetOfName $inner, Cat.Name $outer)
-
This function results in a
Tuple
value that is the same as its$topic
argument but that some of its attributes have been wrapped up into a newTuple
-typed attribute, which exists in place of the original attributes. The$inner
argument specifies which$topic
attributes are to be removed and wrapped up, and the$outer
argument specifies the name of their replacement attribute. As a trivial case, if$inner
is empty, then the result has all the same attributes as before plus a new tuple-typed attribute of degree zero; or, if$inner
lists all attributes of$topic
, then the result has a single attribute whose value is the same as$topic
. This function supports the new attribute having the same name as an old one being wrapped into it. This function will fail if$inner
specifies any attribute names that$topic
doesn't have, or if$outer
is the same as$topic
attributes that aren't being wrapped. sys.Core.Tuple.cmpl_wrap of Tuple (Tuple $topic, Cat.SetOfName $cmpl_inner, Cat.Name $outer)
-
This function is the same as
wrap
but that it wraps the complementary subset of attributes of$topic
to those specified by$cmpl_inner
. sys.Core.Tuple.unwrap of Tuple (Tuple $topic, Cat.Name $outer)
-
This function is the inverse of
sys.Core.Tuple.wrap
, such that it will unwrap aTuple
-type attribute into its member attributes. This function will fail if$outer
specifies any attribute name that$topic
doesn't have, or if an attribute of$topic{$outer}
is the same as another$topic
attribute.
Functions for sys.Core.Tuple.Tuple Having Multiple Input Tuples
sys.Core.Tuple.product of Tuple (QuasiSet{Tuple} $topic)
-
This function is similar to
sys.Core.Relation.product
but that it works with tuples rather than relations. This function is mainly intended for use in connecting tuples that have all disjoint headings, such as for extending one tuple with additional attributes.
Functions for sys.Core.Relation.Relation Having Single Input Relations
sys.Core.Relation.degree of UInt (Relation $topic)
-
This function results in the degree of its argument (that is, the count of attributes it has).
sys.Core.Relation.cardinality of UInt (Relation $topic)
-
This function results in the cardinality of its argument (that is, the count of tuples its body has).
sys.Core.Relation.is_empty of Bool (Relation $topic)
-
This function results in
Bool:true
iff its argument has zero tuples, andBool:false
otherwise. Note that if you are using aMaybe
to represent a sparse data item, analagously to a SQL nullable context, then testing theMaybe
withis_empty
is analagous to testing a SQL nullable withis null
. sys.Core.Relation.is_not_empty of Bool (Relation $topic)
-
This function is exactly the same as
sys.Core.Relation.is_empty
except that it results in the opposite boolean value when given the same argument. And following the analogy withis_empty
,is_not_empty
is analagous to SQL'sis not null
. sys.Core.Relation.is_member of Bool (Relation $r, Tuple $t)
-
This function results in
Bool:true
iff its$t
argument matches a tuple of its$r
argument (that is, iff conceptually$t
is a member of$r
), andBool:false
otherwise. This function is likesys.Core.Relation.is_subset
except that the tuple being looked for doesn't have to be wrapped in a relation. This function will fail if the 2 arguments don't have the same heading. sys.Core.Relation.is_not_member of Bool (Relation $r, Tuple $t)
-
This function is exactly the same as
sys.Core.Relation.is_member
except that it results in the opposite boolean value when given the same arguments. sys.Core.Relation.Tuple_from_Relation of Tuple (Relation $topic)
-
This function results in the
Tuple
that is the sole member tuple of its argument. This function will fail if its argument does not have exactly one tuple. sys.Core.Relation.Relation_from_Tuple of Relation (Tuple $topic)
-
This function results in the
Relation
value those body has just the oneTuple
that is its argument. sys.Core.Relation.insertion of Relation (Relation $r, Tuple $t)
-
This function results in a
Relation
that is the relational union of$r
and a relation whose sole tuple is$t
; that is, conceptually the result is$t
inserted into$r
. As a trivial case, if$t
already exists in$r
, then the result is just$r
. sys.Core.Relation.deletion of Relation (Relation $r, Tuple $t)
-
This function results in a
Relation
that is the relational difference from$r
of a relation whose sole tuple is$t
; that is, conceptually the result is$t
deleted from$r
. As a trivial case, if$t
already doesn't exist in$r
, then the result is just$r
. sys.Core.Relation.empty of Relation (Relation $topic)
-
This function results in the empty relation of the same heading of its argument; it has zero tuples.
sys.Core.Relation.universal of Relation (Relation $topic)
-
This function results in the universal relation of the same heading of its argument; that is, the relation having all the tuples that could ever exist in a relation with that heading. This function will fail if said universal relation is impossible or impractically large to represent, such as when any attributes are of infinite types.
sys.Core.Relation.power_set of Set{Relation} (Relation $topic)
-
This function results in the power set of its argument. The result is a
Set
whose sole attribute isRelation
-typed (its type is nominally the same as that of the argument) and which has a tuple for every distinct subset of tuples in the argument. The cardinality of the result is equal to 2 raised to the power of the cardinality of the argument (which may easily lead to a very large result, so use this function with care). Note that the N-ary relational union of the power set of some relation is that relation; the N-ary intersection of any power set is the empty relation. sys.Core.Relation.negation of Relation (Relation $topic)
-
This function results in the relational negation/not of its argument. The result relation has the same heading as its argument, and its body contains all of the tuples that are in the universal relation of the same heading and that are not in the argument; that is, the result is the relational difference when the argument is subtracted from said universal relation. This function will fail on any argument that
sys.Core.Relation.universal
would fail on. sys.Core.Relation.rename of Relation (Relation $topic, Cat.AttrRenameMap $map)
-
This function is the same as
sys.Core.Tuple.rename
but that it operates on and results in aRelation
rather than aTuple
. sys.Core.Relation.projection of Relation (Relation $topic, Cat.SetOfName $attrs)
-
This function is the same as
sys.Core.Tuple.projection
but that it operates on and results in aRelation
rather than aTuple
. But note that the result relation will have fewer tuples than$topic
if any$topic
tuples were non-distinct for just the projected attributes. sys.Core.Relation.cmpl_projection of Relation (Relation $topic, Cat.SetOfName $attrs)
-
This function is the same as
sys.Core.Tuple.cmpl_projection
but that it operates on and results in aRelation
rather than aTuple
. sys.Core.Relation.wrap of Relation (Relation $topic, Cat.SetOfName $inner, Cat.Name $outer)
-
This function is the same as
sys.Core.Tuple.wrap
but that it operates on and results in aRelation
rather than aTuple
, where each of its member tuples was transformed as persys.Core.Tuple.wrap
. sys.Core.Relation.cmpl_wrap of Relation (Relation $topic, Cat.SetOfName $cmpl_inner, Cat.Name $outer)
-
This function is the same as
sys.Core.Tuple.cmpl_wrap
but that it operates on and results in aRelation
rather than aTuple
, where each of its member tuples was transformed as persys.Core.Tuple.cmpl_wrap
. sys.Core.Relation.unwrap of Relation (Relation $topic, Cat.Name $outer)
-
This function is the inverse of
sys.Core.Relation.wrap
assys.Core.Tuple.unwrap
is tosys.Core.Tuple.wrap
. sys.Core.Relation.group of Relation (Relation $topic, Cat.SetOfName $inner, Cat.Name $outer)
-
This function is similar to
sys.Core.Relation.wrap
but that the$topic
attribute-wrapping transformations result in newRelation
-typed attributes rather than newTuple
-typed attributes, and moreover multiple$topic
tuples may be combined into fewer tuples whose newRelation
-typed attributes have multiple tuples. This function takes a relation of N tuples and divides the tuples into M groups where all the tuples in a group have the same values in the attributes which aren't being grouped (and distinct values in the attributes that are being grouped); it then results in a new relation of M tuples where the new relation-valued attribute of the result has the tuples of the M groups. A grouped relation contains all of the information in the original relation, but it has less redundancy due to redundant non-grouped attributes now just being represented in one tuple per the multiple tuples whose grouped attributes had them in common. A relation having relation-valued attributes like this is a common way to group so-called child tuples under their parents. As a trivial case, if$inner
is empty, then the result has all the same tuples and attributes as before plus a new relation-typed attribute of degree zero whose value per tuple is of cardinality one; or, if$inner
lists all attributes of$topic
, then the result has a single tuple of a single attribute whose value is the same as$topic
. This function supports the new attribute having the same name as an old one being grouped into it. This function will fail if$inner
specifies any attribute names that$topic
doesn't have, or if$outer
is the same as$topic
attributes that aren't being grouped. sys.Core.Relation.cmpl_group of Relation (Relation $topic, Cat.SetOfName $group_per, Cat.Name $outer)
-
This function is the same as
group
but that it groups the complementary subset of attributes of$topic
to those specified by$group_per
. sys.Core.Relation.ungroup of Relation (Relation $topic, Cat.Name $outer)
-
This function is the inverse of
sys.Core.Relation.group
assys.Core.Relation.unwrap
is tosys.Core.Relation.wrap
; it will ungroup aRelation
-type attribute into its member attributes and tuples. A relation can be first grouped and then that result ungrouped to produce the original relation, with no data loss. However, the ungroup of a relation on a relation-valued attribute will lose the information in any outer relation tuples whose inner relation value has zero tuples; a group on this result won't bring them back. This function will fail if$outer
specifies any attribute name that$topic
doesn't have, or if an attribute of$topic{$outer}
is the same as another$topic
attribute. sys.Core.Relation.transitive_closure of Relation (Relation $topic)
-
This function results in the transitive closure of its argument. The argument is a binary relation whose attributes are both of the same declared type, and the result is a relation having the same heading and a body which is a superset of the argument's tuples. Assuming that the argument represents all of the node pairs in a directed graph that have an arc between them, and so each argument tuple represents an arc,
transitive_closure
will determine all of the node pairs in that graph which have a path between them (a recursive operation), so each tuple of the result represents a path. The result is a superset since all arcs are also complete paths. Thetransitive_closure
function is intended to support recursive queries, such as in connection with the "part explosion problem" (the problem of finding all components, at all levels, of some specified part). sys.Core.Relation.reduction of Tuple (Relation $topic, Cat.NameChain $func, Tuple $assuming, Tuple $identity)
-
This function is a generic reduction operator that recursively takes each pair of tuples in
$topic
and applies an argument-specified tuple value-resulting function (which is both commutative and associative) to the pair until just one input tuple is left, which is the result. The function to apply is named in the$func
argument, and that function must have 3 arguments named$v1
,$v2
,$assuming
; the last parameter is curried with the same-named argument ofreduction
, and the first 2 parameters are the 2 input tuples for an invocation. If$topic
has zero tuples, thenreduction
results in the tuple given in$identity
. Note that$identity
may be changed to take a function name rather than a value, for consistency with$func
. This function will fail if the declared headings of$identity
and$topic
aren't compatible. sys.Core.Relation.maybe_reduction of Maybe{Tuple} (Relation $topic, Cat.NameChain $func, Tuple $assuming)
-
This function is exactly the same as
sys.Core.Relation.reduction
except that it does not take an$assuming
argument, and it results in aMaybe
of what is otherwise the result type, and that result has zero elements if the argument has zero elements. sys.Core.Relation.restriction of Relation (Relation $topic, Cat.NameChain $func, Tuple $assuming)
-
This function results in the relational restriction of its
$topic
argument as determined by applying theBool
-resulting function named in its$func
argument when the latter function is curried by its$assuming
argument. The result relation has the same heading as$topic
, and its body contains the subset of$topic
tuples where, for each tuple, the function named by$func
results inBool:true
when passed the tuple as its$topic
argument and$assuming
as its$assuming
argument. As a trivial case, if$func
is defined to unconditionally result inBool:true
, then this function results simply in$topic
; or, for an unconditionalBool:false
, this function results in the empty relation with the same heading. Note that this operation is also legitimately known as where. Note thatsys.Core.Relation.semijoin
is recommended for use instead ofsys.Core.Relation.restriction
to implement some common kinds of relational restrictions (those composed simply of anded or ored tests for attribute value equality), due to the former's greater simplicity. sys.Core.Relation.cmpl_restriction of Relation (Relation $topic, Cat.NameChain $func, Tuple $assuming)
-
This function is the same as
restriction
but that it results in the complementary subset of tuples of$topic
when given the same arguments. sys.Core.Relation.extension of Relation (Relation $topic, Cat.NameChain $func, Tuple $assuming)
-
This function results in the relational extension of its
$topic
argument as determined by applying theTuple
-resulting function named in its$func
argument when the latter function is curried by its$assuming
argument. The result relation has a heading that is a superset of that of$topic
, and its body contains the same number of tuples, with all attribute values of$topic
retained, and possibly extra present, determined as follows; for each$topic
tuple, the function named by$func
results in a second tuple when passed the first tuple as its$topic
argument and$assuming
as its$assuming
argument; the first and second tuples must have no attribute names in common, and the result tuple is derived by joining the tuples together. As a trivial case, if$func
is defined to unconditionally result in the degree-zero tuple, then this function results simply in$topic
. sys.Core.Relation.substitution of Relation (Relation $topic, Cat.NameChain $func, Tuple $assuming)
-
This function is similar to
extension
except that it substitutes values of existing relation attributes rather than adding new attributes. The result relation has the same heading as$topic
. The result tuple of the function named in$func
must have a heading that is a subset of the heading of$topic
; corresponding values resulting from the function named in$func
will replace the values of the tuples of$topic
. The result relation has a cardinality that is the same as that of$topic
, unless the result of any substitutions was redundant tuples, in which case the result has appropriately fewer tuples. As a trivial case, if$func
is defined to unconditionally result in either the degree-zero tuple or in the same tuple as its own$topic
argument, then this function results simply in$topic
; or, if$func
is defined to have a static result and it replaces all attributes, then this function's result will have just 0..1 tuples. sys.Core.Relation.substitution_in_restriction of Relation (Relation $topic, Cat.NameChain $restr_func, Tuple $restr_assuming, Cat.NameChain $subst_func, Tuple $subst_assuming)
-
This function is like
substitution
except that it only transforms a subset of the tuples of$topic
rather than all of them. It is a short-hand for first separating the tuples of$topic
into 2 groups where those passed by a relational restriction (defined by$restr_func
and$restr_assuming
) are then transformed (defined by$subst_func
and$subst_assuming
), then the result of the substitution is unioned with the un-transformed group. Note that thesubstitution_in_semijoin
function is recommended to be used instead for many common substitutions. sys.Core.Relation.map of Relation (Relation $topic, Cat.NameChain $func, Tuple $assuming)
-
This function provides a convenient one-place generalization of per-tuple transformations that otherwise might require the chaining of up to a half-dozen other operators like restriction, extension, and rename. This function results in a relation each of whose tuples is the result of applying, to each of the tuples of its
$topic
argument, theTuple
-resulting function named in its$func
argument when the latter function is curried by its$assuming
argument. There is no restriction on what attributes the result tuple of$func
may have (except that all tuples from$func
must have compatible headings); this tuple from$func
would completely replace the original tuple from$topic
. The result relation has a cardinality that is the same as that of$topic
, unless the result of$func
was redundant tuples, in which case the result has appropriately fewer tuples. As a trivial case, if$func
is defined to unconditionally result in the same tuple as its own$topic
argument, then this function results simply in$topic
; or, if$func
is defined to have a static result, then this function's result will have just 0..1 tuples. sys.Core.Relation.summary of Relation (Relation $topic, Cat.SetOfName $group_per, Cat.NameChain $summ_func, Tuple $summ_assuming)
-
This function provides a convenient context for using aggregate functions to derive a per-group summary relation, which is its result, from another relation, which is its
$topic
argument. This function first performs acmpl_group
on$topic
using$group_per
to specify which attributes get grouped into a new relation-valued attribute and which don't; those that don't instead get wrapped into a tuple-valued attribute. Then, per tuple in the main relation, this function applies theTuple
-resulting function named in its$summ_func
argument when the latter function is curried by its$summ_assuming
argument (passed to it as just$assuming
); the curried function has, rather than the typical 1$topic
varying parameter, 2 varying parameters named$summarize
and$per
, which are valued with the relation-valued attribute and tuple-valued attribute, respectively. As per a function thatmap
applies, the function named by$summ_func
effectively takes a whole post-grouping input tuple and results in a whole tuple; the applied function would directly invoke any N-ary / aggregate operators, and extract their inputs from (or calculate)$summarize
as it sees fit. Note thatsummary
is not intended to be used to summarize an entire$topic
relation at once (except by chance of it resolving to 1 group); you should instead invoke your summarize-all$func
directly, or inline it, rather than by way ofsummary
, especially if you want a single-tuple result on an empty$topic
(whichsummary
) won't do.
Functions for sys.Core.Relation.Relation Having Multiple Input Relations
sys.Core.Relation.is_subset of Bool (Relation $look_in, Relation $look_for)
-
This function results in
Bool:true
iff the set of tuples comprising$look_for
is a subset of the set of tuples comprising$look_in
, andBool:false
otherwise. This function will fail if the 2 arguments don't have the same heading. sys.Core.Relation.is_not_subset of Bool (Relation $look_in, Relation $look_for)
-
This function is exactly the same as
sys.Core.Relation.is_subset
except that it results in the opposite boolean value when given the same arguments. sys.Core.Relation.is_proper_subset of Bool (Relation $look_in, Relation $look_for)
-
This function is exactly the same as
sys.Core.Relation.is_subset
except that it results inBool:false
if its 2 arguments are equal. sys.Core.Relation.is_not_proper_subset of Bool (Relation $look_in, Relation $look_for)
-
This function is exactly the same as
sys.Core.Relation.is_proper_subset
except that it results in the opposite boolean value when given the same arguments. sys.Core.Relation.union of Relation (Set{Relation} $topic)
-
This function results in the relational union/inclusive-or of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and relationally unions (which is both commutative and associative) them together until just one is left, which is the result. The result relation has the same heading as all of its inputs, and its body contains every tuple that is in any of the input relations. If
$topic
has zero values, thenunion
results in the empty relation with the same heading, which is the per-distinct-heading identity value for relational union. sys.Core.Relation.exclusion of Relation (Bag{Relation} $topic)
-
This function results in the relational exclusion/exclusive-or of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and relationally excludes (which is both commutative and associative) them together until just one is left, which is the result. The result relation has the same heading as all of its inputs, and its body contains every tuple that is in just an odd number of the input relations. If
$topic
has zero values, thenexclusion
results in the empty relation with the same heading, which is the per-distinct-heading identity value for relational exclusion. Note that this operation is also legitimately known as symmetric difference, or disjoint union. sys.Core.Relation.intersection of Relation (Set{Relation} $topic)
-
This function results in the relational intersection/and of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and relationally intersects (which is both commutative and associative) them together until just one is left, which is the result. The result relation has the same heading as all of its inputs, and its body contains only the tuples that are in every one of the input relations. If
$topic
has zero values, thenintersection
results in the universal relation with the same heading (that is, the relation having all the tuples that could ever exist in a relation with that heading), which is the per-distinct-heading identity value for relational intersection. Note that this intersection operator is conceptually a special case ofjoin
, applicable when the headings of the inputs are the same, and the other will produce the same result as this when given the same inputs, but with the exception that intersection has a different identity value when given zero inputs. This function will fail on a$topic
of zero values if the result type's universal relation is impossible or impractically large to represent, such as when any attributes are of infinite types. sys.Core.Relation.difference of Relation (Relation $source, Relation $filter)
-
This function results in the relational difference when its
$filter
argument is subtracted from its$source
argument. The result relation has the same heading as both of its arguments, and its body contains only the tuples that are in$source
and are not in$filter
. This function will fail if its 2 arguments do not have the same heading. Note that this difference operator is conceptually a special case of semidifference, applicable when the headings of the inputs are the same. sys.Core.Relation.semidifference of Relation (Relation $source, Relation $filter)
-
This function is the same as
semijoin
but that it results in the complementary subset of tuples of$source
when given the same arguments. Note that this operation is also legitimately known as antijoin. sys.Core.Relation.semijoin of Relation (Relation $source, Relation $filter)
-
This function results in the relational semijoin of its
$source
and$filter
arguments. The result relation has the same heading as$source
, and its body contains the subset of$source
tuples that match those of$filter
as perjoin
. Note that relational semijoin is conceptually a short-hand for first doing an ordinary relational join between its 2 arguments, and then performing a relational projection on all of the attributes that just$source
has. This function will fail any time thatjoin
would fail on the same 2 input relations. sys.Core.Relation.join of Relation (QuasiSet{Relation} $topic)
-
This function results in the relational join of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and relationally joins (which is both commutative and associative) them together until just one is left, which is the result. The result relation has a heading that is a union of all of the headings of its inputs, and its body is the result of first pairwise-matching every tuple of each input relation with every tuple of each other input relation, then where each member of a tuple pair has attribute names in common, eliminating pairs where the values of those attributes differ and unioning the remaining said tuple pairs, then eliminating any result tuples that duplicate others. If
$topic
has zero values, thenjoin
results in the nullary relation with one tuple, which is the identity value for relational join. As a trivial case, if any input relation has zero tuples, then the function's result will too; or, if any input is the nullary relation with one tuple, that input can be ignored (see identity value); or, if any 2 inputs have no attribute names in common, then the join of just those 2 is a cartesian product; or, if any 2 inputs have all attribute names in common, then the join of just those 2 is an intersection; or, if for 2 inputs, one's set of attribute names is a proper subset of another's, then the join of just those to is a semijoin with the former filtering the latter. This function will fail if any input relations have attributes with common names but different/incompatible declared types. Note that this operation is also legitimately known as natural inner join. sys.Core.Relation.product of Relation (QuasiSet{Relation} $topic)
-
This function results in the relational cartesian/cross product of the N element values of its argument; it is conceptually a special case of
join
where all input relations have mutually distinct attribute names; unlikejoin
,product
will fail if any inputs have attribute names in common. Note that this operation is also legitimately known as cartesian/cross join. sys.Core.Relation.composition of Relation (Relation $r1, Relation $r2)
-
This function results in the relational composition of its 2 arguments. It is conceptually a short-hand for first doing an ordinary relational join between its 2 arguments, and then performing a relational projection on all of the attributes that only one of the arguments has; that is, the result has all of and just the attributes that were not involved in matching the tuples of the 2 arguments. This function will fail any time that
join
would fail on the same 2 input relations. sys.Core.Relation.quotient of Relation (Relation $dividend, Relation $divisor)
-
This function results in the quotient when its
$dividend
argument is divided by its$divisor
argument using relational division. Speaking informally, say the relations$dividend
and$divisor
are calledA
andB
, and their attribute sets are respectively named{X,Y}
and{Y}
, then the result relation has a heading composed of attributes{X}
(so the result and$divisor
headings are both complementary subsets of the$dividend
heading); the result has all tuples{X}
such that a tuple{X,Y}
appears inA
for all tuples{Y}
appearing inB
; that is,A / B
is shorthand forA{X} - ((A{X} join B) - A){X}
. sys.Core.Relation.substitution_in_semijoin of Relation (Relation $topic, Relation $restr, Cat.NameChain $subst_func, Tuple $subst_assuming)
-
This function is like
substitution_in_restriction
except that the subset of the tuples of$topic
to be transformed is determined by those matched by a semijoin with$restr
rather than those that pass a generic relational restriction.
Functions for sys.Core.Relation.Set
sys.Core.Set.is_member of Bool (Set $set, Some.ScaTupRel $value)
-
This function results in
Bool:true
iff its$value
argument matches the sole attribute of a tuple of its$set
argument (that is, iff conceptually$value
is a member of$set
), andBool:false
otherwise. This function will fail if the declared type of$value
isn't a subtype of the declared type of the attribute. sys.Core.Set.is_not_member of Bool (Set $set, Some.ScaTupRel $value)
-
This function is exactly the same as
sys.Core.Set.is_member
except that it results in the opposite boolean value when given the same arguments. sys.Core.Set.insertion of Set (Set $set, Some.ScaTupRel $value)
-
This function results in a
Set
that is the relational union of$set
and a Set whose sole tuple has the sole attribute value of$value
; that is, conceptually the result is$value
inserted into$set
. As a trivial case, if$value
already exists in$set
, then the result is just$set
. sys.Core.Set.deletion of Set (Set $set, Some.ScaTupRel $value)
-
This function results in a
Set
that is the relational difference from$set
of a Set whose sole tuple has the sole attribute value of$value
; that is, conceptually the result is$value
deleted from$set
. As a trivial case, if$value
already doesn't exist in$set
, then the result is just$set
. sys.Core.Set.reduction of Some.ScaTupRel (Set $topic, Cat.NameChain $func, Tuple $assuming, Some.ScaTupRel $identity)
-
This function is a generic reduction operator that recursively takes each pair of input values in
$topic
and applies an argument-specified scalar or nonscalar value-resulting function (which is both commutative and associative) to the pair until just one input value is left, which is the result. The function to apply is named in the$func
argument, and that function must have 3 arguments named$v1
,$v2
,$assuming
; the last parameter is curried with the same-named argument ofreduction
, and the first 2 parameters are the 2 input scalar or nonscalar values for an invocation. If$topic
has zero values, thenreduction
results in the value given in$identity
. Note that$identity
may be changed to take a function name rather than a value, for consistency with$func
. This function will fail if the declared type of$identity
isn't a subtype of the declared type of the sole attribute of$topic
. sys.Core.Set.maybe_reduction of Maybe (Set $topic, Cat.NameChain $func, Tuple $assuming)
-
This function is exactly the same as
sys.Core.Set.reduction
except that it does not take an$assuming
argument, and it results in aMaybe
of what is otherwise the result type, and that result has zero elements if the argument has zero elements. sys.Core.Set.Set_from_wrap of Set{Tuple} (Relation $topic)
-
This function results in a
Set
whose sole attribute is tuple-typed and the attribute values are all the tuples of$topic
; is a short-hand for a relational wrap of all attributes of$topic
such that the new tuple-valued attribute is namedvalue
. sys.Core.Set.Set_from_attr of Set (Relation $topic, Cat.Name $name)
-
This function results in a
Set
consisting of all the values of the attribute of$topic
named by$name
. It is a short-hand for a unary projection of just the named attribute plus its renaming tovalue
.
Functions for sys.Core.Relation.Maybe
sys.Core.Maybe.attr_or_default of Some.ScaTupRel (Tuple $topic)
-
This function results in the scalar or nonscalar value of the sole attribute of the sole tuple of its argument, if said tuple exists; otherwise, it results in the default value of the declared type of the said attribute.
sys.Core.Maybe.attr_or_value of Some.ScaTupRel (Tuple $topic, Some.ScaTupRel $value)
-
This function results in the scalar or nonscalar value of the sole attribute of the sole tuple of
$topic
, if said tuple exists; otherwise, it results in$value
. This function will fail if the declared type of$value
isn't a subtype of the declared type of the attribute.
Functions for sys.Core.Relation.Seq
sys.Core.Seq.value of Some.ScaTupRel (Seq $topic, UInt $index)
-
This function results in the scalar or nonscalar
value
attribute of the tuple of$topic
whoseindex
attribute is$index
. This function will fail if no tuple exists in$topic
with the specified index. sys.Core.Seq.update_value of Seq (Seq $topic, UInt $index, Some.ScaTupRel $value)
-
This function results in its
$topic
argument but that thevalue
attribute of the tuple of$topic
whoseindex
attribute is$index
has been updated with a new scalar or nonscalar value given by$value
. This function will fail if no tuple exists in$topic
with the specified index, or if the declared type of$value
isn't a subtype of the declared type of thevalue
attribute. sys.Core.Seq.insertion of Seq (Seq $topic, UInt $index, Some.ScaTupRel $value)
-
This function results in its
$topic
argument but that a new tuple has been inserted whoseindex
is$index
and whosevalue
is$value
; any existing tuples withindex
values greater than or equal to$index
had theirs increased by 1. As a trivial case, if$index
is equal to zero or is equal to the cardinality of$topic
, then$value
has become the new first or last (or only) element, respectively. This function will fail if$index
is greater than the cardinality of$topic
, or if the declared type of$value
isn't a subtype of the declared type of thevalue
attribute. sys.Core.Seq.deletion of Seq (Seq $topic, UInt $index)
-
This function results in its
$topic
argument but that a tuple has been deleted whoseindex
is$index
; any existing tuples withindex
values greater than or equal to$index
had theirs decreased by 1. This function will fail if no tuple exists in$topic
with the specified index. sys.Core.Seq.is_element of Bool (Seq $topic, Some.ScaTupRel $value)
-
This function results in
Bool:true
iff its$value
argument matches thevalue
attribute of at least one tuple of its$topic
argument (that is, iff conceptually$value
is an element of$topic
), andBool:false
otherwise. This function will fail if the declared type of$value
isn't a subtype of the declared type of that attribute. sys.Core.Seq.is_not_element of Bool (Seq $topic, Some.ScaTupRel $value)
-
This function is exactly the same as
sys.Core.Seq.is_element
except that it results in the opposite boolean value when given the same arguments. sys.Core.Seq.reduction of Some.ScaTupRel (Seq $topic, Cat.NameChain $func, Tuple $assuming, Some.ScaTupRel $identity)
-
This function is the same as
sys.Core.Set.reduction
, including that input values for the reduction come from thevalue
attribute of$topic
, except that it works with aSeq
rather than aSet
. Also, the function named in$func
is only associative, and not commutative; the arguments to$v1
and$v2
of$func
are guaranteed to be consecutive input elements, with the result returning to their place in sequence beween the other input elements. sys.Core.Seq.maybe_reduction of Maybe (Seq $topic, Cat.NameChain $func, Tuple $assuming)
-
This function is to
sys.Core.Set.maybe_reduction
assys.Core.Seq.reduction
is tosys.Core.Set.reduction
. sys.Core.Seq.catenation of Seq (Seq{Seq} $topic)
-
This function results in the catenation of the N element values of its argument; it is a reduction operator that recursively takes each consecutive pair of input values and catenates (which is associative) them together until just one is left, which is the result. To catenate 2
Seq
means to union their tuples after first increasing all theindex
values of the second one by the cardinality of the first one. If$topic
has zero values, thencatenate
results in the empty sequence value, which is the identity value for catenate. sys.Core.Seq.repeat of Seq (Seq $topic, UInt $count)
-
This function results in the catenation of
$count
instances of$topic
. sys.Core.Seq.reverse of Seq (Seq $topic)
-
This function results in its argument but that the order of its elements has been reversed. For example, the input
{ 0=
'a', 1=>'b', 2=>'c', 3=>'d'}> results in{ 0=
'd', 1=>'c', 2=>'b', 3=>'a' }>. sys.Core.Seq.is_subseq of Bool (Seq $look_in, Seq $look_for)
-
This function results in
Bool:true
iff the sequence of values comprising$look_for
is a sub-sequence of the sequence of values$look_in
, andBool:false
otherwise. This function will fail if the 2 arguments don't have the same heading. sys.Core.Seq.is_not_subseq of Bool (Seq $look_in, Seq $look_for)
-
This function is exactly the same as
sys.Core.Seq.is_subseq
except that it results in the opposite boolean value when given the same arguments.
Functions for sys.Core.Relation.Bag
sys.Core.Bag.cardinality of UInt (Bag $topic)
-
This function is like
sys.Core.Relation.cardinality
but that it accounts for the greater-than-one multiplicity of values in its argument; it results in the sum of thecount
attribute of its argument. sys.Core.Bag.is_member of Bool (Bag $bag, Some.ScaTupRel $value)
-
This function is the same as
sys.Core.Set.is_member
, including that matching of$value
is done against thevalue
attribute, except that it works with aBag
rather than aSet
. sys.Core.Bag.is_not_member of Bool (Bag $bag, Some.ScaTupRel $value)
-
This function is exactly the same as
sys.Core.Bag.is_member
except that it results in the opposite boolean value when given the same arguments. sys.Core.Bag.count of UInt (Bag $bag, Some.ScaTupRel $value)
-
This function results in the multiplicity / count of occurrances of
$value
in$bag
; if a tuple exists in$bag
whosevalue
attribute is$value
, then the result is itscount
attribute; otherwise the result is zero. sys.Core.Bag.insertion of Bag (Bag $bag, Some.ScaTupRel $value)
-
This function is the same as
sys.Core.Set.insertion
as peris_member
but that its result differs depending on whether$value
already exists in$bag
; if it does, then no new tuple is added, but thecount
attribute for the matching tuple is increased by 1; if it does not, then a new tuple is added where itsvalue
is$value
and itscount
is 1. sys.Core.Bag.deletion of Bag (Bag $bag, Some.ScaTupRel $value)
-
This function is the same as
sys.Core.Set.deletion
as peris_member
but that its result differs depending on what thecount
for any tuple matching$value
that already exists in$bag
is; if thecount
is greater than 1, then it is decreased by 1; if it is equal to 1, then the tuple whosevalue
is$value
is deleted. sys.Core.Bag.reduction of Some.ScaTupRel (Bag $topic, Cat.NameChain $func, Tuple $assuming, Some.ScaTupRel $identity)
-
This function is the same as
sys.Core.Set.reduction
, including that input values for the reduction come from thevalue
attribute of$topic
, except that it works with aBag
rather than aSet
;$func
is invoked extra times, where both its$v1
and$v2
arguments might be different instances of the same value having >= 2 multiplicity. sys.Core.Bag.maybe_reduction of Maybe (Bag $topic, Cat.NameChain $func, Tuple $assuming)
-
This function is to
sys.Core.Set.maybe_reduction
assys.Core.Bag.reduction
is tosys.Core.Set.reduction
. sys.Core.Bag.Set_from_Bag of Set (Bag $topic)
-
This function results in the
Set
that is the projection of thevalue
attribute of itsBag
argument. sys.Core.Bag.Bag_from_Set of Bag (Set $topic)
-
This function results in the
Bag
that is the extension of itsSet
argument with a newcount
attribute whose value for every tuple is 1. sys.Core.Bag.Bag_from_wrap of Bag{Tuple} (Relation $topic)
-
This function results in a
Bag
whosevalue
attribute is tuple-typed and that attribute's values are all the tuples of$topic
; is a short-hand for a relational wrap of all attributes of$topic
such that the new tuple-valued attribute is namedvalue
, and then that result is extended with acount
attribute whose value for every tuple is 1. sys.Core.Bag.Bag_from_attr of Bag (Relation $topic, Cat.Name $name)
-
This function results in a
Bag
consisting of all the values of the attribute of$topic
named by$name
. It is a short-hand for first doing a relational group on all attributes of$topic
besides$name
to produce a new relation-typed attribute, and then extending the result of the group with a new positive integer attribute whose values are the cardinality of the relation-valued attribute's values, and then doing a binary projection of the named attribute and the new integer attribute plus their renaming tovalue
andcount
respectively. sys.Core.Bag.is_subset of Bool (Bag $look_in, Bag $look_for)
-
This function is like
sys.Core.Relation.is_subset
but that it accounts for the greater-than-one multiplicity of values in its arguments; this function returnsBool:true
iff the multiplicity of each$look_for
value is less than or equal to the multiplicity of its counterpart$look_in
value. sys.Core.Bag.is_not_subset of Bool (Bag $look_in, Bag $look_for)
-
This function is like
sys.Core.Relation.is_not_subset
as peris_subset
. sys.Core.Bag.is_proper_subset of Bool (Bag $look_in, Bag $look_for)
-
This function is like
sys.Core.Relation.is_proper_subset
as peris_subset
. TODO: What is its definition? sys.Core.Bag.is_not_proper_subset of Bool (Bag $look_in, Bag $look_for)
-
This function is like
sys.Core.Relation.is_not_proper_subset
as peris_subset
. TODO: What is its definition? sys.Core.Bag.union of Bag (Set{Bag} $topic)
-
This function is like
sys.Core.Relation.union
but that it just looks at thevalue
attribute of its argument elements when determining what element tuples correspond; then for each tuple in the result, itscount
attribute value is the maximum of thecount
attribute values of its corresponding input element tuples. sys.Core.Bag.intersection of Bag (Set{Bag} $topic)
-
This function is like
sys.Core.Relation.intersection
asunion
is likesys.Core.Relation.union
; the minimum ofcount
attribute values is used rather than the maximum. sys.Core.Bag.difference of Bag (Bag $source, Bag $filter)
-
This function is like
sys.Core.Relation.difference
asunion
is likesys.Core.Relation.union
; for corresponding input tuples, the result only has a tuple with the samevalue
if thecount
of the$source
tuple is greater than thecount
of the$filter
tuple, and thecount
of the result tuple is the difference of those two.
SYSTEM-DEFINED CORE GENERIC QUASI-NONSCALAR FUNCTIONS
This documentation is pending.
SYSTEM-DEFINED CORE UPDATE OPERATORS
Generic Universal
These update operators are applicable to values of any data type at all.
sys.Core.Universal.assign (UPD: Some.Universal $target ; RO: Some.Universal $v)
-
This update operator will update the variable supplied as its
$target
argument so that it holds the value supplied as its$v
argument. This update operator's arguments must be of compatible declared types; in this case,$v
must be a subtype of$target
.
Scalar
These update operators are applicable to just one or more specific system-defined core scalar data type.
This documentation is pending.
Nonscalar
These update operators are applicable to mainly nonscalar types, but are generic in that they typically work with any nonscalar types.
Quasi-Nonscalar
This documentation is pending.
SYSTEM-DEFINED CORE SYSTEM SERVICES
These system services are applicable to just one or more specific system-defined core scalar data type.
This documentation is pending.
SYSTEM-DEFINED CORE PROCEDURES
Generic Control-Flow Procedures
These procedures are applicable to use in all kinds of procedures.
sys.Core.Control.fail (RO: Cat.Exception $topic)
-
This procedure will throw the exception given as its argument; this results in the call stack unwinding, and transaction rollbacks, until it is caught.
sys.Core.Control.try_catch (UPD: Tuple $try_updating, Tuple $catch_updating ; RO: Cat.NameChain $try, Cat.NameChain $catch, Tuple $try_assuming, Tuple $catch_assuming)
-
This procedure invokes the procedure named in its
$try
argument, giving it the arguments$try_updating
and$try_assuming
as its$updating
and$assuming
arguments, respectively. If the$try
procedure throws an exception, then any state changes it made roll back (but changes made before that don't), and the call stack unwinds to thetry_catch
itself; then the procedure named by$catch
is invoked similarly to$try
was, with corresponding arguments, but with the extra read-only argument$topic
whose value is aCat.Exception
; if the$catch
procedure also throws an exception (such as to say its not handling the thrown one), then that one is not caught and the call stack unwinding plus applicable transaction rollback carries on to the caller of thetry_catch
. If the$try
procedure succeeds (doesn't throw an exception), then the$catch
procedure is not called.
SEE ALSO
Go to Language::MuldisD for the majority of distribution-internal references, and Language::MuldisD::SeeAlso for the majority of distribution-external references.
AUTHOR
Darren Duncan (perl@DarrenDuncan.net
)
LICENSE AND COPYRIGHT
This file is part of the formal specification of the Muldis D language.
Muldis D is Copyright © 2002-2007, Darren Duncan.
See the LICENSE AND COPYRIGHT of Language::MuldisD for details.
ACKNOWLEDGEMENTS
The ACKNOWLEDGEMENTS in Language::MuldisD apply to this file too.
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 1575:
You forgot a '=back' before '=head2'
- Around line 1580:
'=item' outside of any '=over'