NAME

Muldis::D::Ext::Set - Muldis D extension for Set and Maybe specific operators

VERSION

This document is Muldis::D::Ext::Set version 0.92.0.

PREFACE

This document is part of the Muldis D language specification, whose root document is Muldis::D; 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 Set document describes the system-defined Muldis D Set Extension, which consists of generic operators that are specific to the Set and Maybe parameterized relation types, and said operators are short-hands for generic relational operators in the language core.

This current document does not describe the polymorphic operators that all types, or some types including core types, have defined over them; said operators are defined once for all types in Muldis::D::Core.

This documentation is pending.

SYSTEM-DEFINED SET-CONCERNING FUNCTIONS

sys.std.Set.has_member

function sys.std.Set.has_member (Bool <-- Set $set, Universal $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), and Bool:false otherwise. This function will warn if its 2 arguments are incompatible as per sys.std.Core.Relation.is_subset. Note that this operation is also known as S∋.

sys.std.Set.has_not_member

function sys.std.Set.has_not_member (Bool <-- Set $set, Universal $value)

This function is exactly the same as sys.std.Set.has_member except that it results in the opposite boolean value when given the same arguments. Note that this operation is also known as S∌.

sys.std.Set.value_is_member

function sys.std.Set.value_is_member (Bool <-- Universal $value, Set $set)

This function is an alias for sys.std.Set.has_member. 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), and Bool:false otherwise. Note that this operation is also known as S∈.

sys.std.Set.value_is_not_member

function sys.std.Set.value_is_not_member (Bool <-- Universal $value, Set $set)

This function is an alias for sys.std.Set.has_not_member. This function is exactly the same as sys.std.Set.value_is_member except that it results in the opposite boolean value when given the same arguments. Note that this operation is also known as S¬in;.

sys.std.Set.insertion

function sys.std.Set.insertion (Set <-- Set $set, Universal $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.std.Set.disjoint_ins

function sys.std.Set.disjoint_ins (Set <-- Set $set, Universal $value)

This function is exactly the same as sys.std.Set.insertion except that it will fail if value already exists in set.

sys.std.Set.deletion

function sys.std.Set.deletion (Set <-- Set $set, Universal $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.std.Set.reduction

function sys.std.Set.reduction (Universal <-- Set $topic, ValRedFuncRef $func, Universal $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 value_reduction function (which is both commutative and associative) to the pair until just one input value is left, which is the result. The value_reduction function to apply is named in the func argument, and that function must have 2 parameters named v1 and v2, which take the 2 input scalar or nonscalar values for an invocation. If topic has zero values, then reduction 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|warn if the |declared type of identity isn't a subtype of the |declared type of the sole attribute of topic.

sys.std.Set.maybe_reduction

function sys.std.Set.maybe_reduction (Maybe <-- Set $topic, ValRedFuncRef $func)

This function is exactly the same as sys.std.Set.reduction except that it does not take an identity argument, and it results in a Maybe of what is otherwise the result type, and that result has zero elements if the argument has zero elements.

sys.std.Set.Set_from_wrap

function sys.std.Set.Set_from_wrap (set_of.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 named value.

sys.std.Set.Set_from_attr

function sys.std.Set.Set_from_attr (Set <-- Relation $topic, 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 to value.

SYSTEM-DEFINED MAYBE-CONCERNING FUNCTIONS

sys.std.Set.Maybe.nothing

function sys.std.Set.Maybe.nothing (Maybe <--)

This named_value selector function results in the only zero-tuple Maybe value, which is known by the special name Maybe:nothing, aka nothing, aka empty set aka .

sys.std.Set.Maybe.single

function sys.std.Set.Maybe.single (Single <-- Universal $value)

This selector function results in the Maybe value with a single tuple whose value attribute's value is the value argument. Note that this operation is also known as s.

sys.std.Set.Maybe.attr

function sys.std.Set.Maybe.attr (Universal <-- Single $topic)

This function results in the scalar or nonscalar value of the sole attribute of the sole tuple of its argument, which always exists when the argument is a Single. Note that this operation is also known as v.

sys.std.Set.Maybe.attr_or_default

function sys.std.Set.Maybe.attr_or_default (Universal <-- array_of.Maybe $topic?, TypeRef $default)

This function results in the scalar or nonscalar value of the sole attribute of the sole tuple of the lowest-indexed of its N topic input element values where said element isn't equal to nothing, if there is such an element; otherwise, it results in the default value of the scalar or nonscalar data type whose name is given in the default argument. This function is a short-hand for invoking attr_or_value with the result from invoking sys.std.Core.Universal.default. Note that this operation is also known as //d.

sys.std.Set.Maybe.attr_or_value

function sys.std.Set.Maybe.attr_or_value (Universal <-- array_of.Maybe $topic?, Universal $value)

This function results in the scalar or nonscalar value of the sole attribute of the sole tuple of the lowest-indexed of its N topic input element values where said element isn't equal to nothing, if there is such an element, and otherwise it results in value. This function will warn if the declared type of value isn't a subtype of the declared type of the attribute. Note that this operation is also known as //. In situations where a Maybe is used analagously to a SQL nullable value, this function is analagous to the N-adic SQL COALESCE function.

sys.std.Set.Maybe.order

function sys.std.Set.Maybe.order (Order <-- Maybe $topic, Maybe $other, Bool $treat_nothing_as_max, OrdDetFuncRef $ord_func?, Bool $reverse_order_of_singles?)

This function is a generic (total) order_determination function for Maybe values. Iff both of its topic and other arguments are identical, this function results in Order:same. Otherwise, iff both of those 2 arguments are Single values, then the result of this function is the result of applying to those 2 arguments the (total) order_determination function given in its ord_func argument, as curried by its reverse_order_of_singles argument. Otherwise, iff topic is nothing, this function results in Order:increase or Order:decrease respectively when treat_nothing_as_max is Bool:false (the default) or Bool:true. Otherwise (iff other is nothing), this function results in the reverse of when only topic is nothing. In situations where a Maybe is used analagously to a SQL nullable value and this function is analagous to the dyadic comparison underlying a SQL "ORDER BY", then reverse_order_of_singles designates SQL's "ASC|DESC" and treat_nothing_as_max designates SQL's "NULLS FIRST|LAST".

SEE ALSO

Go to Muldis::D for the majority of distribution-internal references, and Muldis::D::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-2009, Muldis Data Systems, Inc.

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

TRADEMARK POLICY

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

ACKNOWLEDGEMENTS

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