=pod

=encoding utf8

=head1 NAME

Muldis::D::Core::Types_Catalog -
Muldis D catalog-defining data types

=head1 VERSION

This document is Muldis::D::Core::Types_Catalog version 0.24.1.

=head1 PREFACE

This document is part of the Muldis D language specification, whose root
document is L<Muldis::D>; you should read that root document before
you read this one, which provides subservient details.  Moreover, you
should read the L<Muldis::D::Core> document before this current
document, as that forms its own tree beneath a root document branch.

=head1 DESCRIPTION

This document contains one or more sections that were moved here from
L<Muldis::D::Core> so that that other document would not be too
large.

These core data types are more special-purpose in nature and are intended
for use in defining or working with the system catalog.  Those types that
are nonscalar are completely defined types.

Note that whenever an attribute of one of the tuple 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.

Note that many of the tuple types might conceptually have C<name>
attributes, but those would actually be provided by any larger types in
which they are embedded, rather than by these types themselves.

I<To keep things simpler for now, most constraint definitions for these
types are missing, or just defined informally.>

=head1 TYPE SUMMARY

These system-defined subtypes are specific to defining the system catalog,
more or less:

    sys.Core.Type.Universal

        sys.Core.Type.Empty

        sys.Core.Type.Scalar

            # The following are all regular ordered scalar types.

            sys.Core.Type.Cat.Name
            sys.Core.Type.Cat.NameChain
            sys.Core.Type.Cat.DeclNameChain
            sys.Core.Type.Cat.Comment

            # The following are all regular non-ordered scalar types.

            sys.Core.Type.Cat.E_TK
            sys.Core.Type.Cat.E_TDM

        sys.Core.Type.Tuple

            # The following are all regular tuple types.

            sys.Core.Type.Cat.System
            sys.Core.Type.Cat.Federation
            sys.Core.Type.Cat.Depot
            sys.Core.Type.Cat.Package
            sys.Core.Type.Cat.FuncHead
            sys.Core.Type.Cat.UpdHead
            sys.Core.Type.Cat.ProcHead
            sys.Core.Type.Cat.FuncBody
            sys.Core.Type.Cat.UpdBody
            sys.Core.Type.Cat.ProcBody
            sys.Core.Type.Cat.InnerFuncBody
            sys.Core.Type.Cat.ExprNodeSet
            sys.Core.Type.Cat.InnerUpdBody
            sys.Core.Type.Cat.InnerProcBody
            sys.Core.Type.Cat.ProcStmt
            sys.Core.Type.Cat.Type
            sys.Core.Type.Cat.Exception

        sys.Core.Type.Relation

            # The following are all regular relation types.

            sys.Core.Type.Cat.SysNspSet
            sys.Core.Type.Cat.Sys(Func|Upd|Proc)Set
            sys.Core.Type.Cat.DepotMountSet
            sys.Core.Type.Cat.SubdepotSet
            sys.Core.Type.Cat.PackageSet
            sys.Core.Type.Cat.Dep(Func|Upd|Proc)Set
            sys.Core.Type.Cat.Pkg(Func|Upd|Proc)Set
            sys.Core.Type.Cat.Inner(Func|Upd|Proc)Set
            sys.Core.Type.Cat.ScaLitExprNodeSet
            sys.Core.Type.Cat.ScaPRLitExprNodeSet
            sys.Core.Type.Cat.TupLitExprNodeSet
            sys.Core.Type.Cat.RelLitExprNodeSet
            sys.Core.Type.Cat.FuncInvoExprNodeSet
            sys.Core.Type.Cat.MultiUpdStmt
            sys.Core.Type.Cat.NameTypeMap
            sys.Core.Type.Cat.NameExprMap
            sys.Core.Type.Cat.AttrRenameMap

            sys.Core.Type.Set

                # The following are all regular set types.

                sys.Core.Type.Cat.SetOfName
                sys.Core.Type.Cat.SetOfNameExprMap
                sys.Core.Type.Cat.SetOfSetOfName
                sys.Core.Type.Cat.SetOfNameChain

            sys.Core.Type.Seq

                # The following are all regular sequence types.

                sys.Core.Type.Cat.SeqOfProcStmt

These system-defined subtypes are used as the declared types of some
parameters of some system-defined N-ary routines, but they are not used in
defining the system catalog itself; it is not anticipated that they would
be used for user data:

    sys.Core.Type.Universal

        sys.Core.Type.Empty

        sys.Core.Type.Relation
            sys.Core.Type.Set

                # The following are all nonscalar type factories.

                sys.Core.Type.QuasiCat.SetOfTuple
                sys.Core.Type.QuasiCat.SetOfRelation
                    sys.Core.Type.QuasiCat.SetOfBag

                sys.Core.Type.Maybe

                    # The following are all nonscalar type factories.

                    sys.Core.Type.QuasiCat.MaybeOfTuple

            sys.Core.Type.Seq

                # The following are all nonscalar type factories.

                sys.Core.Type.QuasiCat.SeqOfSeq

            sys.Core.Type.Bag

                # The following are all nonscalar type factories.

                sys.Core.Type.QuasiCat.BagOfTuple
                sys.Core.Type.QuasiCat.BagOfRelation

        sys.Core.Type.QuasiRelation
            sys.Core.Type.QuasiSet

                # The following are all quasi-nonscalar type factories.

                sys.Core.Type.QuasiCat.QuasiSetOfTuple
                sys.Core.Type.QuasiCat.QuasiSetOfRelation

=head1 TYPES FOR DEFINING ENTITY NAMES AND COMMENTS

=head2 sys.Core.Type.Cat.Name

A C<Cat.Name> (scalar) 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
C<Cat.Name>, depending on the context; other times, a C<Cat.NameChain> must
be used instead to also qualify the reference with a namespace.
C<Cat.Name> is the same as C<Text> in representation (each value as a
string of characters) and cardinality though its values are distinct; it is
specifically intended for use in naming DBMS entities rather than being for
general-purpose user data.  The default value et al is as for C<Text>.

=head2 sys.Core.Type.Cat.NameChain

A C<Cat.NameChain> (scalar) is a canonical long name for invoking or
referring to a DBMS entity, when its name needs to be qualified with a
namespace.  A C<Cat.NameChain> is conceptually a sequence of 2..N
C<Cat.Name>, the 2..N elements being ordered from parent-most to child-most
component name.  A C<Cat.NameChain> has 2 system-defined possreps, named
C<seq> and C<flat>, both of which are defined over C<Cat.Name>.

The C<seq> possrep directly matches the conception of the type; it consists
of 1 attribute whose name is the empty string; the attribute is a C<Seq>
whose C<value> attribute has a declared type of C<Cat.Name> and that must
have at least 2 elements.

The C<flat> possrep consists of 1 attribute whose name is the empty string;
the attribute is a C<Cat.Name>, its value being identical to when the
elements of the first possrep are catenated (in order with the first
element at the start of the string), with a period (C<.>) between the
parts, and each part escaped such that backslashes, single-quotes, and
periods are escaped as C<\b>, C<\q> and C<\p> respectively.

The default and minimum value of C<Cat.NameChain> is a 2 element sequence
where each element is the default value of C<Cat.Name> (the empty string);
its maximum value is an infinite sequence where each element is the maximum
value of C<Cat.Name> (an infinite-length string) and practically
impossible.  The cardinality of this type is infinity; to define a
most-generalized finite C<Cat.NameChain> subtype, you must specify a
maximum number of sequence elements of its values, and each element must be
of a finite C<Cat.Name> subtype.

=head2 sys.Core.Type.Cat.DeclNameChain

A C<Cat.DeclNameChain> (scalar) is mostly the same as a C<Cat.NameChain>
but that it is a sequence of 0..N rather than 2..N, and that its C<flat>
possrep has N+1 periods rather than N-1; the possrep starts with a period,
and also has a period just following each sequence element, and so an empty
sequence means a C<flat> possrep consisting of just a period.  A
C<Cat.DeclNameChain> is used in declaring system catalogs where DBMS
entities live under a potentially N-depth namespace, such as depot entities
grouped in a subdepot hierarchy.  The default and minimum value of
C<Cat.DeclNameChain> is a zero element sequence.

=head2 sys.Core.Type.Cat.Comment

A C<Cat.Comment> (scalar) is the text of a Muldis D code comment, which
programmers can populate as an attribute of several catalog data types,
such as whole routines or statements or expression nodes.  C<Cat.Comment>
is exactly the same as C<Cat.Name> in representation and cardinality though
its values are distinct; it is intended just for commenting Muldis D code.
One main intended use of this type is to help preserve comments in code
translated to or from other languages; though only a subset of those
(FoxPro?) keep comments in the AST rather than discarding them.  The
default value et al is as for C<Cat.Name>.

=head1 TYPES FOR DEFINING SYSTEM-DEFINED ENTITIES

=head2 sys.Core.Type.Cat.System

A C<Cat.System> is a C<Tuple>.  It specifies the public interfaces of
system-defined entities, specifically all the system-defined types,
routines, and catalogs.  Both standard system-defined entities and
implementation-specific system-defined entities are specified here,
specifically all the relcons and relvars with the names
C<(sys|mnt|fed|dep|sdp|pkg).cat>.  The system catalog constant named
C<sys.cat> is of the C<Cat.System> type.

A C<Cat.System> has these N attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the collection of
system-defined entities as a whole.

=item C<namespaces> - C<Cat.SysNspSet>

These are all the system-defined namespaces where DBMS entities may live.

=item C<functions|updaters|procedures> - C<Cat.Sys(Func|Upd|Proc)Set>

These are the interfaces of all the system-defined
functions|updaters|procedures.

=item C<types> - C<Cat.SysTypeSet>

These are the interfaces of all the system-defined types.

=item C<catalogs> - C<Cat.SysCatSet>

These are the interfaces of all the catalog relcons, relvars.

=back

The default value of C<Cat.System> defines a system with zero builtins.

=head2 sys.Core.Type.Cat.SysNspSet

A C<Cat.SysNspSet> is a C<Relation> that specifies the set of system
namespaces that exist for organizing DBMS public entities, mostly the
system-defined ones; these system namespaces are organized into a tree
whose root has no name.  A C<Cat.SysNspSet> only specifies that a system
namespace exists, not which public entities it contains; see the
C<Cat.System> which contains it for that.

A C<Cat.SysNspSet> has these 3 attributes:

=over

=item C<parent> - I<TODO.>

I<TODO.>

=item C<name> - C<Cat.Name>

This is the declared name of the system namespace within the namespace
defined by C<parent>; other Muldis D code would reference it with the
combination of C<parent> and C<name>.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about this specific system
namespace.

=back

A C<Cat.SysNspSet> has a binary (unique) key on the C<parent> plus
C<name> attributes.  Its default value is empty.

=head2 sys.Core.Type.Cat.Sys(Func|Upd|Proc)Set

A C<Cat.Sys(Func|Upd|Proc)Set> is a C<Relation> that specifies a set of
system-defined functions|updaters|procedures.

A C<Cat.Sys(Func|Upd|Proc)Set> has these 4 attributes:

=over

=item C<parent> - I<TODO.>

I<TODO.>

=item C<name> - C<Cat.Name>

This is the declared name of the function|updater|procedure within the
namespace defined by C<parent>; other Muldis D code would reference it with
the combination of C<parent> and C<name>.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the function|updater|procedure
as a whole.

=item C<head> - C<Cat.(Func|Upd|Proc)Head>

This defines the entire function|updater|procedure heading, that is its
public interface sans the name, which is all the details of how to use it
and no more detail than necessary about how it is implemented.

=back

A C<Cat.Sys(Func|Upd|Proc)Set> has a binary (unique) key on the C<parent>
plus C<name> attributes.  Its default value is empty.

=head1 TYPES FOR DEFINING FEDERATIONS

=head2 sys.Core.Type.Cat.Federation

A C<Cat.Federation> is a C<Tuple>.  It specifies a federation of depot
mounts, that is, all the depot mounts that an in-DBMS process can see or
update, and that defines the scope of an active transaction.  There is
exactly one of these per process and it doesn't have a name.  The system
catalog variable named C<fed.cat> is of the C<Cat.Federation> type.

A C<Cat.Federation> has these 2 attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the federation as a whole.

=item C<mounts> - C<Cat.DepotMountSet>

These are the depot mounts that comprise the federation.

=back

The default value of C<Cat.Federation> has zero depot mounts.

=head2 sys.Core.Type.Cat.DepotMountSet

A C<Cat.DepotMountSet> is a C<Relation> that specifies a set of depot
mounts, such that each tuple is a single depot mount.  A depot mount is a
named in-DBMS context by which a depot is referenced from either other
depots or by the main application, and it also specifies the catalog
content of the depot itself.

A C<Cat.DepotMountSet> has these 3 attributes:

=over

=item C<name> - C<Cat.Name>

This is the declared name of the depot mount; other Muldis D code would
reference it with this name.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about this specific mount of the
depot.

=item C<depot> - C<Cat.Depot>

This defines the entire system catalog of the depot that this mount has
made visible to the DBMS.

=back

A C<Cat.DepotMountSet> has a unary (unique) key on the C<name> attribute.
Its default value is empty.

=head1 TYPES FOR DEFINING DEPOTS AND SUBDEPOTS

=head2 sys.Core.Type.Cat.Depot

A C<Cat.Depot> is a C<Tuple>.  It specifies the entire system catalog of a
single depot, that is, the widest scope within which all entities must be
fully defined in terms of just user-defined entities within the same scope
or of system-defined entities.  It also doubles to specify the system
catalog of a subdepot, which is an arbitrary subset of a depot's entities
that internally looks like a depot; a depot can have 0..N subdepots, and
any that exist are arranged in a hierarchy with the depot as the root.  The
system catalog variables named C<dep.cat> and C<sdp.cat> are both of the
C<Cat.Depot> type.

A C<Cat.Depot> has these N attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the (|sub)depot as a whole.

=item C<subdepots> - C<Cat.SubdepotSet>

These are all the subdepots that this (|sub)depot contains.

=item C<packages> - C<Cat.PackageSet>

These are all the packages that this (|sub)depot contains.

=item C<functions|updaters|procedures> - C<Cat.Dep(Func|Upd|Proc)Set>

These are all the function|updater|procedure definitions that this
(|sub)depot contains.

=item C<types> - C<Cat.DepTypeSet>

These are all the type definitions that this (|sub)depot contains.
TODO: possibly split into scalar|tuple|relation|etc

=item C<vars> - TODO: all public variables or pseudo-variables or something

=item C<data> - TODO: the single main/root database variable

=back

The default value of C<Cat.Depot> defines an empty (|sub)depot.

=head2 sys.Core.Type.Cat.SubdepotSet

A C<Cat.SubdepotSet> is a C<Relation> that specifies the set of subdepots
that a depot might optionally have for organizing its public entities;
these subdepots are organized into a tree whose root is the depot.  A
C<Cat.SubdepotSet> only specifies that a subdepot exists, not which depot
entities it contains; see the C<Cat.Depot> which contains it for that.

A C<Cat.SubdepotSet> has these 3 attributes:

=over

=item C<parent> - C<Cat.DeclNameChain>

This is the fully-qualified name, in the C<dep.(cat|lib|data)> namespace,
of the subdepot's parent subdepot, which is often just the depot itself.

=item C<name> - C<Cat.Name>

This is the declared name of the subdepot within the namespace defined by
C<parent>; other Muldis D code would reference it with the combination of
C<parent> and C<name>.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about this specific subdepot.

=back

A C<Cat.SubdepotSet> has a binary (unique) key on the C<parent> plus
C<name> attributes.  Its default value is empty.

=head2 sys.Core.Type.Cat.PackageSet

A C<Cat.PackageSet> is a C<Relation> that specifies the set of packages
that a depot might optionally have for organizing its possibly private
entities.

A C<Cat.PackageSet> has these 4 attributes:

=over

=item C<parent> - C<Cat.DeclNameChain>

This is the fully-qualified name, in the C<dep.(cat|lib|data)> namespace,
of the packages's parent (|sub)depot.

=item C<name> - C<Cat.Name>

This is the declared name of the package within the namespace defined by
C<parent>; other Muldis D code would reference it with the combination of
C<parent> and C<name>.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the package definition as
associated with this package name.

=item C<package> - C<Cat.Depot>

This defines the entire system catalog of the package.

=back

A C<Cat.PackageSet> has a binary (unique) key on the C<parent> plus
C<name> attributes.  Its default value is empty.

=head2 sys.Core.Type.Cat.Dep(Func|Upd|Proc)Set

A C<Cat.Dep(Func|Upd|Proc)Set> is a C<Relation> that specifies a set of
functions|updaters|procedures that a (|sub)depot might directly contain.

A C<Cat.Dep(Func|Upd|Proc)Set> has these 5 attributes:

=over

=item C<parent> - C<Cat.DeclNameChain>

This is the fully-qualified name, in the C<dep.(cat|lib|data)> namespace,
of the function|updater|procedure's parent (|sub)depot.

=item C<name> - C<Cat.Name>

This is the declared name of the function|updater|procedure within the
namespace defined by C<parent>; other Muldis D code would reference it with
the combination of C<parent> and C<name>.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the function|updater|procedure
as a whole.

=item C<head> - C<Cat.(Func|Upd|Proc)Head>

This defines the entire function|updater|procedure heading, that is its
public interface sans the name, which is all the details of how to use it
and no more detail than necessary about how it is implemented.

=item C<body> - C<Cat.(Func|Upd|Proc)Body>

This defines the entire function|updater|procedure body, that is its
implementation, besides what C<interface> defines.

=back

A C<Cat.Dep(Func|Upd|Proc)Set> has a binary (unique) key on the C<parent>
plus C<name> attributes.  Its default value is empty.

=head1 TYPES FOR DEFINING PACKAGES

=head2 sys.Core.Type.Cat.Package

A C<Cat.Package> is a C<Tuple>.  It specifies the entire system catalog of
a single package, which provides a privatizing namespace for a subset of a
depot's entities; entities outside a package can only invoke that package's
entities which have been declared part of its public interface.  A package
internally looks like a depot but that it doesn't contain subdepots or
other packages.  The system catalog variable named C<pkg.cat> is of the
C<Cat.Package> type.

A C<Cat.Package> has these N attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the package as a whole.

=item C<functions|updaters|procedures> - C<Cat.Pkg(Func|Upd|Proc)Set>

These are all the function|updater|procedure definitions that this package
contains.

=item C<types> - C<Cat.PkgTypeSet>

These are all the type definitions that this package contains.

=item C<vars> - TODO: all public variables or pseudo-variables or something

=item C<data> - TODO: the single main/root database variable

=back

The default value of C<Cat.Package> defines an empty package.

=head2 sys.Core.Type.Cat.Pkg(Func|Upd|Proc)Set

A C<Cat.Pkg(Func|Upd|Proc)Set> is a C<Relation> that specifies a set of
functions|updaters|procedures that a package might contain, where each
function|updater|procedure may be either public for the DBMS as a whole or
private to the package.

A C<Cat.Pkg(Func|Upd|Proc)Set> has these 5 attributes:

=over

=item C<name> - C<Cat.Name>

This is the declared name of the function|updater|procedure.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the function|updater|procedure
as a whole.

=item C<is_public> - C<Bool>

This is C<Bool:true> if the function|updater|procedure is part of the
package's own public interface and may be invoked from outside the package;
it is C<Bool:false> if it is just part of the package's internals.

=item C<head> - C<Cat.(Func|Upd|Proc)Head>

This defines the entire function|updater|procedure heading, that is its
public interface sans the name, which is all the details of how to use it
and no more detail than necessary about how it is implemented.

=item C<body> - C<Cat.(Func|Upd|Proc)Body>

This defines the entire function|updater|procedure body, that is its
implementation, besides what C<interface> defines.

=back

A C<Cat.Pkg(Func|Upd|Proc)Set> has a unary (unique) key on the C<name>
attribute.  Its default value is empty.

=head1 TYPES FOR DEFINING ROUTINE HEADINGS

=head2 sys.Core.Type.Cat.FuncHead

A C<Cat.FuncHead> is a C<Tuple>.  It specifies the entire heading or public
interface of a function or inner function, except for its name and
public/private status; the latter are provided by any type embedding this
one when applicable.

A C<Cat.FuncHead> has these 3 attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the function heading.

=item C<result_type> - C<Cat.NameChain>

This is the declared result data type of the function as a whole.

=item C<params> - C<Cat.NameTypeMap>

This is the declared parameter list of the function, which has 0..N named
and typed parameters.

=back

The default value of C<Cat.FuncHead> has zero parameters and a result type
of C<Bool>.

=head2 sys.Core.Type.Cat.UpdHead

A C<Cat.UpdHead> is a C<Tuple>.  It specifies the entire heading or public
interface of an updater or inner updater, except for its name and
public/private status; the latter are provided by any type embedding this
one when applicable.

A C<Cat.UpdHead> has these 3 attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the updater heading.

=item C<upd_params> - C<Cat.NameTypeMap>

This is the declared subject-to-update parameter list of the updater, which
has 1..N named and typed such parameters.  It must have at least 1 element.

=item C<ro_params> - C<Cat.NameTypeMap>

This is the declared read-only parameter list of the updater, which has
0..N named and typed such parameters.

=back

There is a distributed (unique) key over the C<name> attributes of
C<upd_params> and C<ro_params>.

The default value of C<Cat.UpdHead> has 1 subject-to-update parameter whose
name is C<topic> and whose declared type is C<Bool>; it has zero read-only
parameters.

=head2 sys.Core.Type.Cat.ProcHead

A C<Cat.ProcHead> is a C<Tuple>.  It specifies the entire heading or public
interface of a procedure or inner procedure, except for its name and
public/private status; the latter are provided by any type embedding this
one when applicable.

A C<Cat.ProcHead> has these 3 attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the procedure heading.

=item C<upd_params> - C<Cat.NameTypeMap>

This is the declared subject-to-update parameter list of the procedure,
which has 0..N named and typed such parameters.

=item C<ro_params> - C<Cat.NameTypeMap>

This is the declared read-only parameter list of the procedure, which has
0..N named and typed such parameters.

=back

There is a distributed (unique) key over the C<name> attributes of
C<upd_params> and C<ro_params>.

The default value of C<Cat.ProcHead> has zero parameters.

=head1 TYPES FOR DEFINING ROUTINE BODIES

=head2 sys.Core.Type.Cat.FuncBody

A C<Cat.FuncBody> is a C<Tuple>.  It specifies the entire body or
implementation of a function, besides the details that a C<Cat.FuncHead>
has, one of which each C<Cat.FuncBody> typically must be paired with.

A C<Cat.FuncBody> has these N attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the function body.

=item C<main_body> - C<Cat.InnerFuncBody>

This defines the entire main body of the function, namely what's left of
the function body after parts of it are optionally factored out into inner
routines or inner types.  It must consist of a value expression whose
result type is of the result type of the function, and which invokes all of
the function's parameters.

=item C<inner_funcs> - C<Cat.InnerFuncSet>

These are all the inner function definitions that this function contains.

=item C<inner_types> - C<Cat.InnerTypeSet>

These are all the inner type definitions that this function contains.

=back

There is a distributed (unique) key over the C<name> attributes of
C<inner_(funcs|types)>.

The default value of C<Cat.FuncBody> directly corresponds to the default
value of C<Cat.FuncHead> and unconditionally results in the value
C<Bool:false>.

=head2 sys.Core.Type.Cat.UpdBody

A C<Cat.UpdBody> is a C<Tuple>.  It specifies the entire body or
implementation of an updater, besides the details that a C<Cat.UpdHead>
has, one of which each C<Cat.UpdBody> typically must be paired with.

A C<Cat.UpdBody> has these N attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the updater body.

=item C<main_body> - C<Cat.InnerUpdBody>

This defines the entire main body of the updater, namely what's left of the
updater body after parts of it are optionally factored out into inner
routines or inner types.  It must consist of a multi-update statement which
invokes all of the updater's parameters.

=item C<inner_upds> - C<Cat.InnerUpdSet>

These are all the inner updater definitions that this updater contains.

=item C<inner_funcs> - C<Cat.InnerFuncSet>

These are all the inner function definitions that this updater contains.

=item C<inner_types> - C<Cat.InnerTypeSet>

These are all the inner type definitions that this updater contains.

=back

There is a distributed (unique) key over the C<name> attributes of
C<inner_(upds|funcs|types)>.

The default value of C<Cat.UpdBody> directly corresponds to the default
value of C<Cat.UpdHead> and unconditionally updates its C<topic> argument
to the value C<Bool:false>.

=head2 sys.Core.Type.Cat.ProcBody

A C<Cat.ProcBody> is a C<Tuple>.  It specifies the entire body or
implementation of a procedure, besides the details that a C<Cat.ProcHead>
has, one of which each C<Cat.ProcBody> typically must be paired with.

A C<Cat.ProcBody> has these N attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the procedure body.

=item C<main_body> - C<Cat.InnerProcBody>

This defines the entire main body of the procedure, namely what's left of
the procedure body after parts of it are optionally factored out into inner
routines or inner types.

=item C<inner_procs> - C<Cat.InnerProcSet>

These are all the inner procedure definitions that this procedure contains.

=item C<inner_upds> - C<Cat.InnerUpdSet>

These are all the inner updater definitions that this procedure contains.

=item C<inner_funcs> - C<Cat.InnerFuncSet>

These are all the inner function definitions that this procedure contains.

=item C<inner_types> - C<Cat.InnerTypeSet>

These are all the inner type definitions that this procedure contains.

=back

There is a distributed (unique) key over the C<name> attributes of
C<inner_(procs|upds|funcs|types)>.

The default value of C<Cat.ProcBody> directly corresponds to the default
value of C<Cat.ProcHead> and is a no-op, having zero statements.

=head2 sys.Core.Type.Cat.Inner(Func|Upd|Proc)Set

A C<Cat.Inner(Func|Upd|Proc)Set> is a C<Relation> that specifies a set of
inner functions|updaters|procedures that a function|updater|procedure might
contain.

A C<Cat.Inner(Func|Upd|Proc)Set> has these 4 attributes:

=over

=item C<name> - C<Cat.Name>

This is the declared name of the inner function|updater|procedure.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the inner
function|updater|procedure as a whole.

=item C<head> - C<Cat.(Func|Upd|Proc)Head>

This defines the entire inner function|updater|procedure heading, that is
its public interface sans the name, which is all the details of how to use
it and no more detail than necessary about how it is implemented.

=item C<body> - C<Cat.Inner(Func|Upd|Proc)Body>

This defines the entire inner function|updater|procedure body, that is its
implementation, besides what C<interface> defines.

=back

A C<Cat.Inner(Func|Upd|Proc)Set> has a unary (unique) key on the C<name>
attribute.  Its default value is empty.

=head1 TYPES FOR DEFINING INNER ROUTINE BODIES

=head2 sys.Core.Type.Cat.InnerFuncBody

A C<Cat.InnerFuncBody> is a C<Tuple>.  It specifies the entire body or
implementation of an inner function (or the main body of a function),
besides the details that a C<Cat.FuncHead> has, one of which each
C<Cat.InnerFuncBody> typically must be paired with.

A C<Cat.InnerFuncBody> has these 2 attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the (|inner )function body.

=item C<expr> - C<Cat.ExprNodeSet>

This defines the value expression tree that comprises the entire (|inner
)function body.

=back

There is a distributed (unique) key over the C<name> attributes of all the
attributes of C<expr>; and if this C<Cat.InnerFuncBody> is paired with a
C<Cat.FuncHead>, then the distributed key also extends over the head's
parameter names.

A C<Cat.InnerFuncBody> specifies a simple value expression tree of named
expression nodes, each of which is a tuple of one of its C<expr.\w+_exprs>
attributes.  It must have at least 1 member node, except that it may have
zero member nodes iff the (|inner )function it is composed into has exactly
1 parameter, in which case the value expression tree implicitly results in
the argument to said parameter.  Otherwise:  All member nodes must define a
simple expression node tree, such that every member except one (which is
the root node) has one of its peers as a parent node, and no direct cycles
between members are permitted (only indirect cycles based on (|inner
)function invocations are allowed); the name of the root node must be the
empty string.  Note that the composed-into (|inner )function's parameters
are also implicitly tree nodes, and are referenced by name into the
expression the same way as any other named expression node is.  Regardless
of whether the node count is zero or 1+, the tree must denote a value
expression whose result type is of the result type of the (|inner )function
it is composed into, and which invokes all of the (|inner )function's
parameters.

The default value of C<Cat.InnerFuncBody> directly corresponds to the
default value of C<Cat.FuncHead> and unconditionally results in the value
C<Bool:false>.

=head2 sys.Core.Type.Cat.ExprNodeSet

A C<Cat.ExprNodeSet> is a C<Tuple> that specifies a set of named value
expression nodes.  It is typically composed into a (|inner
)(function|updater). Each tuple of a C<Cat.ExprNodeSet> attribute is 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 expression nodes, either directly,
or indirectly by way of (|inner )function invocations, as each (|inner
)function body is itself composed entirely of a single expression tree (of
at least 1 node).  Only functions and updaters may contain expression
nodes, so for any procedures that would conceptually include them, those
portions of the procedures need to be separated out and encapsulated by
named (|inner )functions or (|inner )updaters.  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 (|inner )updaters where the expression is used as an argument
for a subject-to-update parameter of an (|inner )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 (|inner )update operator.

A C<Cat.ExprNodeSet> has these 5 attributes:

=over

=item C<sca_lit_exprs> - C<Cat.ScaLitExprNodeSet>

These are expression nodes that define scalar literals of types such that
the Muldis D dialect provides special literal syntax specific to the type,
and the type may not have any possreps.

=item C<sca_pr_lit_exprs> - C<Cat.ScaPRLitExprNodeSet>

These are expression nodes that define (|quasi-)scalar literals of types
such that each type has at least 1 possrep, and each literal is specified
simply in terms of possrep attributes.

=item C<tup_lit_exprs> - C<Cat.TupLitExprNodeSet>

These are expression nodes that define (|quasi-)tuple literals.

=item C<rel_lit_exprs> - C<Cat.RelLitExprNodeSet>

These are expression nodes that define (|quasi-)relation literals.

=item C<func_invo_exprs> - C<Cat.FuncInvoExprNodeSet>

These are expression nodes that invoke (|inner )functions.

=back

There is a distributed (unique) key over the C<name> attributes of all of a
C<Cat.ExprNodeSet>'s attributes.  Its default value is empty.

=head2 sys.Core.Type.Cat.ScaLitExprNodeSet

A C<Cat.ScaLitExprNodeSet> is a C<Relation> that specifies a set of value
expression nodes where each node is a hard-coded scalar literal of one of a
certain collection of system-defined core scalar types (or subtype
thereof).

A C<Cat.ScaLitExprNodeSet> has these 3 attributes:

=over

=item C<name> - C<Cat.Name>

This is the declared name of the expression node.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about either the expression node or
the expression node (sub-)tree it is the root of.

=item C<value> - C<Scalar>

This is the actual literal value that the expression node represents.
I<That is, any Scalar value could be used here, but in practice that is
either dialect-defined (what literals are supported), and possibly
implementation defined/limited.>

=back

A C<Cat.ScaLitExprNodeSet> has a unary (unique) key on the C<name>
attribute.  Its default value is empty.

=head2 sys.Core.Type.Cat.ScaPRLitExprNodeSet

A C<Cat.ScaPRLitExprNodeSet> is a C<Relation> that specifies a set of value
expression nodes where each node represents a (|quasi-)scalar literal of a
type that has at least 1 possrep, and the literal is specified simply in
terms of possrep attributes.

A C<Cat.ScaPRLitExprNodeSet> has these 6 attributes:

=over

=item C<name> - C<Cat.Name>

This is the declared name of the expression node.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about either the expression node or
the expression node (sub-)tree it is the root of.

=item C<is_quasi> - C<Bool>

This is C<Bool:true> if the node denotes a quasi-scalar literal; it is
C<Bool:false> if the node just denotes a scalar literal.

=item C<type_name> - C<Cat.NameChain>

This is the name of the type that the (|quasi-)scalar value belongs to.

=item C<possrep_name> - C<Cat.Name>

This is the name of the possrep, of the type named by C<scalar_type_name>,
in terms of whose attributes the (|quasi-)scalar value is being selected.

=item C<possrep_attrs> - C<Cat.NameExprMap>

These are the attributes (names and values) of the C<possrep_name> possrep
of the (|quasi-)scalar literal.

=back

A C<Cat.ScaPRLitExprNodeSet> has a unary (unique) key on the C<name>
attribute.  Its default value is empty.

=head2 sys.Core.Type.Cat.TupLitExprNodeSet

A C<Cat.TupLitExprNodeSet> is a C<Relation> that specifies a set of value
expression nodes where each node represents a (|quasi-)tuple literal.

A C<Cat.TupLitExprNodeSet> has these 4 attributes:

=over

=item C<name> - C<Cat.Name>

This is the declared name of the expression node.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about either the expression node or
the expression node (sub-)tree it is the root of.

=item C<is_quasi> - C<Bool>

This is C<Bool:true> if the node denotes a quasi-tuple literal; it is
C<Bool:false> if the node just denotes a tuple literal.

=item C<attrs> - C<Cat.NameExprMap>

These are the attributes (names and values) of the (|quasi-)tuple literal.

=back

A C<Cat.TupLitExprNodeSet> has a unary (unique) key on the C<name>
attribute.  Its default value is empty.

=head2 sys.Core.Type.Cat.RelLitExprNodeSet

A C<Cat.RelLitExprNodeSet> is a C<Relation> that specifies a set of value
expression nodes where each node represents a (|quasi-)relation literal.

A C<Cat.RelLitExprNodeSet> has these 5 attributes:

=over

=item C<name> - C<Cat.Name>

This is the declared name of the expression node.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about either the expression node or
the expression node (sub-)tree it is the root of.

=item C<is_quasi> - C<Bool>

This is C<Bool:true> if the node denotes a quasi-relation literal; it is
C<Bool:false> if the node just denotes a relation literal.

=item C<head> - C<Cat.SetOfName>

These are the names of all of this (|quasi-)relation literal's attributes.

=item C<body> - C<Cat.SetOfNameExprMap>

These are the (|quasi-)tuples of the (|quasi-)relation literal.

=back

A C<Cat.RelLitExprNodeSet> has a unary (unique) key on the C<name>
attribute.  Its default value is empty.

=head2 sys.Core.Type.Cat.FuncInvoExprNodeSet

A C<Cat.FuncInvoExprNodeSet> is a C<Relation> that specifies a set of value
expression nodes where each node represents the result of invoking a named
(|inner )function with specific arguments.

A C<Cat.FuncInvoExprNodeSet> has these 4 attributes:

=over

=item C<name> - C<Cat.Name>

This is the declared name of the expression node.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about either the expression node or
the expression node (sub-)tree it is the root of.

=item C<function> - C<Cat.NameChain>

This is the name of the (|inner )function being invoked.

=item C<args> - C<Cat.NameExprMap>

These are the arguments for the (|inner )function invocation.  Each element
defines one argument value, with the element C<name> matching the invoked
(|inner )function's parameter name, and the element C<expr> naming another
local expression node which defines the value.

=back

A C<Cat.FuncInvoExprNodeSet> has a unary (unique) key on the C<name>
attribute. Its default value is empty.

=head2 sys.Core.Type.Cat.InnerUpdBody

A C<Cat.InnerUpdBody> is a C<Tuple>.  It specifies the entire body or
implementation of an inner updater (or the main body of a updater), besides
the details that a C<Cat.UpdHead> has, one of which each
C<Cat.InnerUpdBody> typically must be paired with.

A C<Cat.InnerUpdBody> has these 3 attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the (|inner )updater body.

=item C<exprs> - C<Cat.ExprNodeSet>

This defines the expression trees that are arguments to the update
operators that C<stmt> invokes.  These expression trees must reference all
of the parameters that the inner update operator has.

=item C<stmt> - C<Cat.MultiUpdStmt>

This defines the entire body of the (|inner )updater, which is composed of
a single multi-update statement.  This multi-update statement must
reference all of the parameters that the (|inner )updater has.

=back

There is a distributed (unique) key over the C<name> attributes of all the
attributes of C<exprs>; and if this C<Cat.InnerUpdBody> is paired with a
C<Cat.UpdHead>, then the distributed key also extends over the head's
parameter names.

The default value of C<Cat.InnerUpdBody> directly corresponds to the
default value of C<Cat.UpdHead> and unconditionally updates its C<topic>
argument to the value C<Bool:false>.

=head2 sys.Core.Type.Cat.MultiUpdStmt

A C<Cat.MultiUpdStmt> is a C<Relation> that specifies a multi-update
statement (of 1..N variables), which is the narrowest scope implicitly
atomic component of procedural Muldis D code.  It is the most fundamental
component of procedural Muldis D code.  The variables being updated are
accessed via the host (|inner )updater's subject-to-update parameters.  All
arbitrarily complex Muldis D value assignments, including relational
assignments, are composed of just C<Cat.MultiUpdStmt>, either directly, or
indirectly by way of (|inner )updater invocations, as each (|inner )updater
body is itself composed entirely of 1 multi-update statement (plus
supporting value expressions).  Only (|inner )updaters may contain
C<Cat.MultiUpdStmt>, so for any procedures that would conceptually include
them, those portions of the procedures need to be separated out and
encapsulated by named (|inner )updaters.  Each tuple of a multi-update
statement is a single update statement, which represents a single
invocation of an (|inner )updater, and at least 1 tuple is required.

A C<Cat.MultiUpdStmt> has these 4 attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the single update statement as
a whole.

=item C<updater> - C<Cat.NameChain>

This is the name of the (|inner )updater being invoked.

=item C<upd_args> - C<Cat.NameExprMap>

These are the 1..N subject-to-update arguments to the (|inner )updater
invocation, as-per C<ro_args>.  But since each expression tree in
C<upd_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, the parameter is referenced directly.

=item C<ro_args> - C<Cat.NameExprMap>

These are the 0..N read-only arguments to the (|inner )updater invocation.
Each element defines one argument value, with the element C<name> matching
the invoked routine's parameter name, and the element C<expr> naming a
local expression node (or parameter) which defines the value.

=back

There is a distributed (unique) key over the C<name> attributes of
C<upd_args> and C<ro_args>.

The default value of C<Cat.MultiUpdStmt> directly corresponds to the
default value of C<Cat.InnerUpdBody> and unconditionally updates its
containing (|inner )updater's C<topic> argument to the value C<Bool:false>.

=head2 sys.Core.Type.Cat.InnerProcBody

A C<Cat.InnerProcBody> is a C<Tuple>.  It specifies the entire body or
implementation of an inner procedure (or the main body of a procedure),
besides the details that a C<Cat.ProcHead> has, one of which each
C<Cat.InnerProcBody> typically must be paired with.

A C<Cat.InnerProcBody> has these 3 attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the (|inner )procedure body.

=item C<vars> - C<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.

=item C<stmts> - C<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.

=back

There is a distributed (unique) key over the C<name> attributes of all the
attributes of C<vars>; and if this C<Cat.InnerProcBody> is paired with a
C<Cat.ProcHead>, then the distributed key also extends over the head's
parameter names.

The default value of C<Cat.InnerProcBody> directly corresponds to the
default value of C<Cat.ProcHead> and is a no-op, having zero statements.

=head2 sys.Core.Type.Cat.SeqOfProcStmt

A C<Cat.SeqOfProcStmt> is a C<Seq> whose C<value> attribute has a declared
type of C<Cat.ProcStmt>.

=head2 sys.Core.Type.Cat.ProcStmt

A C<Cat.ProcStmt> is a C<Tuple>.  It specifies a generic statement from
which non-implicitly-atomic procedural Muldis D code is composed.  Only
(|inner )procedure may contain C<Cat.ProcStmt>.

A C<Cat.ProcStmt> has these 4 attributes:

=over

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the statement as a whole.

=item C<procedure> - C<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.

=item C<upd_args> - C<Cat.NameExprMap>

These are the 0..N subject-to-update arguments to the routine invocation,
as-per C<ro_args>.

=item C<ro_args> - C<Cat.NameExprMap>

These are the 0..N read-only arguments to the routine invocation.  Each
element defines one argument value, with the element C<name> matching the
invoked routine's parameter name, and the element C<expr> naming a local or
global variable or statement-containing routine parameter which defines the
value.

=back

There is a distributed (unique) key over the C<name> attributes of
C<upd_args> and C<ro_args>.

The default value of C<Cat.ProcStmt> will invoke
C<sys.Core.Universal.assign>, giving it arguments from same-named and typed
parameters.

=head1 SIMPLE GENERIC CATALOG COLLECTION TYPES

=head2 sys.Core.Type.Cat.NameTypeMap

A C<Cat.NameTypeMap> is a C<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 I<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 C<Cat.NameTypeMap> has 2 attributes,
C<name> (a C<Cat.Name>) and C<type> (a C<Cat.NameChain>); the C<name> is
the declared name of the attribute or parameter, and comprises a unary key;
the C<type> is the declared data type of the attribute or parameter.  Its
default value has zero tuples.

=head2 sys.Core.Type.Cat.NameExprMap

A C<Cat.NameExprMap> is a C<Relation>.  It defines a basic component-values
list, meaning a set of names, with a declared local expression node (or
parameter or variable) name for each.  It is used to define collection
literals; one C<Cat.NameExprMap> defines a whole C<Tuple> value.  It is
also used to define argument lists for routine invocations.  A
C<Cat.NameExprMap> has 2 attributes, C<name> (a C<Cat.Name>) and C<expr> (a
C<Cat.NameChain>); the C<name> is the name of the tuple/etc attribute or
routine argument, and comprises a unary key; the C<expr> is the declared
local name of the expression node (or parameter or variable) which defines
the value for the attribute or argument.  Note that while the C<expr>
attribute could conceivably just be a C<Cat.Name> because most of its
allowed values would be in the C<lex> namespace, the C<Cat.NameChain> is
used instead so that value expressions can take advantage of terse syntax
for addressing value attributes.  Its default value has zero tuples.

=head2 sys.Core.Type.Cat.AttrRenameMap

A C<Cat.AttrRenameMap> is a C<Relation>.  It is used as a specification for
how to rename attributes of some collection.  A C<Cat.AttrRenameMap> has 2
attributes, C<before> and C<after>, each of those being a C<Cat.Name>, and
each of those being a unary key.  Its default value has zero tuples.

=head2 sys.Core.Type.Cat.SetOfName

A C<Cat.SetOfName> is a C<Set> whose C<value> attribute has a declared type
of C<Cat.Name>.

=head2 sys.Core.Type.Cat.SetOfNameExprMap

A C<Cat.SetOfNameExprMap> is a C<Set> whose C<value> attribute has a
declared type of C<Cat.NameExprMap>.

=head1 OLD TYPE DEFINITIONS TO REWRITE OR REPLACE

=head2 sys.Core.Type.Cat.E_TK

A C<Cat.E_TK> (type kind) is a scalar enumeration consisting of the 8
values C<Cat.E_TK:special> (mainly for system-defined implicit supertypes),
C<Cat.E_TK:scalar>, C<Cat.E_TK:tuple>, C<Cat.E_TK:relation>,
C<Cat.E_TK:quasi_scalar>, C<Cat.E_TK:quasi_tuple>,
C<Cat.E_TK:quasi_relation>, C<Cat.E_TK:remnant>.  Its default value is
C<Cat.E_TK:scalar>.

=head2 sys.Core.Type.Cat.E_TDM

A C<Cat.E_TDM> (type definition method) is a scalar enumeration consisting
of the 9 values C<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), C<Cat.E_TDM:root> (complete root type
defined in terms of explicit attribute collection; all are fully defined,
not parameterized), C<Cat.E_TDM:restriction> (defined as "explicit
other-type where condition"), C<Cat.E_TDM:alias> (so the same one type can
have multiple names), C<Cat.E_TDM:(union|intersection|exclusion)> (defined
as explicit union|intersection|exclusion of other types),
C<Cat.E_TDM:difference> (defined as explicit difference of 2 other types),
C<Cat.E_TDM:negation> (defined as explicit negation of another type).  Its
default value is C<Cat.E_TDM:alias>.

=head2 sys.Core.Type.Cat.Type

A C<Cat.Type> is a C<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.  C<Cat.Type> is used in the catalogs for defining
both system and user types (just the interfaces in the former case).

I<TODO:  The catalog types for type definitions need an overhaul.>

A C<Cat.Type> has these 8 attributes:

=over

=item C<tk> - C<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.

=item C<tdm> - C<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 C<tk> is C<Cat.E_TK:special>, then C<tdm> must be
C<Cat.E_TDM:special>; C<tdm> can be special at other times too.

=item C<types> - C<Cat.SetOfNameChain>

For some values of C<tdm>, the data type is defined at least partially in
terms of other data types not by way of attribute definitions, and then
C<types> lists all/most of those types.  Iff C<tdm> is C<Cat.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), and C<types> has one element that is the name
of that type.  Iff C<tdm> is C<Cat.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, and C<types> has one element that is
the name of that supertype.  Iff C<tdm> is
C<Cat.E_TDM:(union|intersection|exclusion)>, then the data type is defined
as an explicit union|intersection|exclusion of N other types, and C<types>
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 type
C<Empty>, C<Universal>, or C<Empty>.  Iff C<tdm> is
C<Cat.E_TDM.difference>, then the data type is defined as the difference of
2 other types, and C<types> has one element that is the name of the minuend
type.  Iff C<tdm> is C<Cat.E_TDM.negation>, then the data type is defined
as the negation of some other type, and C<types> has one element that is
the name of that type.

=item C<subtr_type> - C<Cat.NameChain>

Iff C<tdm> is C<Cat.E_TDM.difference>, then the data type is defined as the
difference of 2 other types, and C<subtr_type> is the name of the
subtrahend type.

=item C<attrs> - C<Cat.NameTypeMap>

Iff C<tdm> is C<Cat.E_TDM:root>, then the data type is defined
fundamentally in terms of an explicit attribute collection, and C<attrs>
defines the names and declared types of those attributes.  Iff additionally
C<tk> is C<Cat.E_TK:(scalar|quasi_scalar)>, then C<attrs> specifically
defines the attributes of just the core/initial/only possrep; otherwise,
C<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.

=item C<keys> - C<Cat.SetOfSetOfName>

Iff C<tk> is C<Cat.E_TK:(relation|quasi_relation)> and C<tdm> is not
C<Cat.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, and C<keys> defines those keys in the canonical simplest form
(in contrast with using C<constraint> instead).  Each element of C<keys>
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.

=item C<constraint> - C<Cat.TypeConstraint> ... default one always res True

Iff C<tdm> is C<Cat.E_TDM:root>, then the data type is defined
fundamentally in terms of an explicit attribute collection, and
C<constraint> defines/names a generalized type constraint that validates
the collection as a whole.  Iff C<tdm> is C<Cat.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, and C<constraint>
defines/names that further constraint.

=item C<comment> - C<Cat.Comment>

This is an optional programmer comment about the data type.

=back

The default value of C<Cat.Type> is an alias of C<Empty>.

=head2 sys.Core.Type.Cat.Exception

I<TODO.>

=head2 sys.Core.Type.Cat.SetOfSetOfName

A C<Cat.SetOfSetOfName> is a C<Set> whose C<value> attribute has a declared
type of C<Cat.SetOfName>.

=head2 sys.Core.Type.Cat.SetOfNameChain

A C<Cat.SetOfNameChain> is a C<Set> whose C<value> attribute has a declared
type of C<Cat.NameChain>.

=head1 SYSTEM-DEFINED CORE QUASI-CATALOG PARAMETERIZED TYPES

These types are incomplete proper subtypes of other core incomplete types,
and generally speaking their sole purpose is to be the declared data types
of several system-defined N-ary tuple|relation operator parameters which
are collections of generic nonscalar values.  They are called quasi-catalog
because they are not generally expected to be used for user data, but they
also are not used to compose the system catalog either.

=over

=item C<sys.Core.Type.QuasiCat.(Set|Bag)Of(Tuple|Relation)>

A C<(Set|Bag)OfRelation> is an incompletely defined proper subtype of
C<Set|Bag> whose C<value> attribute has a declared type of a
C<Tuple|Relation> subtype; this is the parameter type of several N-ary
relational operators.

=item C<sys.Core.Type.QuasiCat.SetOfBag>

A C<SetOfBag> is an incompletely defined proper subtype of C<Set> whose
C<value> attribute has a declared type of a C<Bag> subtype; this is the
parameter type of several N-ary relational operators that work with C<Bag>
values.

=item C<sys.Core.Type.QuasiCat.MaybeOfTuple>

A C<MaybeOfTuple> is an incompletely defined proper subtype of C<Maybe>
whose C<value> attribute has a declared type of a C<Tuple> subtype; this is
the parameter type of the C<sys.Nonscalar.Relation.maybe_reduction>
operator.

=item C<sys.Core.Type.QuasiCat.SeqOfSeq>

A C<SeqOfSeq> is an incompletely defined proper subtype of C<Seq> whose
C<value> attribute has a declared type of a C<Seq> subtype; this is the
parameter type of the N-ary C<sys.Sequence.catenation> operator.

=item C<sys.Core.Type.QuasiCat.QuasiSetOf(Tuple|Relation)>

A C<QuasiSetOfRelation> is an incompletely defined proper subtype of
C<QuasiSet> whose C<value> attribute has a declared type of
C<Tuple|Relation>; these are the parameter types of the N-ary
C<sys.Core.Tuple.product> and C<sys.Core.Relation.(join|product)>
operators.

=back

=head1 SEE ALSO

Go to L<Muldis::D> for the majority of distribution-internal
references, and L<Muldis::D::SeeAlso> for the majority of
distribution-external references.

=head1 AUTHOR

Darren Duncan (C<perl@DarrenDuncan.net>)

=head1 LICENSE AND COPYRIGHT

This file is part of the formal specification of the Muldis D language.

Muldis D is Copyright © 2002-2008, Darren Duncan.

See the LICENSE AND COPYRIGHT of L<Muldis::D> for details.

=head1 TRADEMARK POLICY

The TRADEMARK POLICY in L<Muldis::D> applies to this file too.

=head1 ACKNOWLEDGEMENTS

The ACKNOWLEDGEMENTS in L<Muldis::D> apply to this file too.

=cut
