Set Language-Independent Type for YAML™ Version 1.1

Working Draft 2005-01-18

Oren Ben-Kiki

Clark Evans

Brian Ingerson

This document may be freely copied provided it is not modified.

Status

This specification is a draft reflecting consensus reached by members of the yaml-core mailing list. Any questions regarding this draft should be raised on this list.


URI:

tag:yaml.org,2002:set

Shorthand:

!!set

Kind:

Mapping.

Definition:

Unordered set of non-equal values.

A set is an unordered collection of nodes such that no two nodes are equal. While sets are a fundamental mathematical type, YAML only supports them as the domains of a mapping. Hence the YAML syntax for a set is a mapping with all-null values.

Most programming languages do not have a built-in native data type for supporting sets. Such data types are usually provided by libraries. If no such data type is available, an application may resort to loading a “!!set” into a native hash table where all values are null.

The “!!set” tag may be given explicitly. Alternatively, the application may choose to implicitly type mappings with all-null values to sets. In this case, an explicit “!!map” transfer must be given to mappings that have all-null values but do not represent sets.

Example 1. !!set Examples

# Explicitly typed set.
baseball players: !!set
  ? Mark McGwire
  ? Sammy Sosa
  ? Ken Griffey
# Flow style
baseball teams: !!set { Boston Red Sox, Detroit Tigers, New York Yankees }