Module Cduce_types__AtomSet
Sets of atoms, used for variants (`nil, `true, `false, …) as well as for XML tags (<hello>[] ≡ <(`hello)>[]).
The type t of sets of atoms with its basic operations. Since atoms live in an open world (basically the set of valid XML tags) such a set can either be finite (listing explicitely the elements it contains) or co-finite (listing explicitely the elements it does not contain). Furthermore, each such finite or cofinite set can be restrited to a particular namespace.
include Cduce_types.Tset.S with type elem = V.t
include Cduce_types.Tset.Tset_base
val empty : tThe empty set
val any : tThe full set, containing all possible values for this kind.
Set operations :
module Infix : sig ... endType specific operations:
Membership:
val is_empty : t -> boolis_empty tchecks whetertis the empty set.
val single : t -> V.tsingle tassumestis a singleton and returns its unique element.- raises [Not_found]
if
tis the empty set
- raises [Exit]
if
tcontains more than one element
type sample= (Ns.Uri.t * Ns.Label.t option) optionThe type of a
samplethat is a representation of an element of the set.
val sample : t -> samplesample treturns a sample fortfor instance iftisanyreturnsNone. Iftcontains only co-finite sets for some namespacesns1,ns2, … returnsSome (ns1, None). Finaly, iftcontains at least one element,sample treturnsSome(ns, Some l)wherensis the namespace andlthe local name.- raises [Not_found]
if
tis empty.
Formatting functions :
val print : t -> (Stdlib.Format.formatter -> unit) listprint treturns, for each namespaces in the sett, a function that prints the set of atoms in that namespace (thus calling each function, separated with"|"prints the whole set).
val print_tag : t -> (Stdlib.Format.formatter -> unit) optionprint_tag treturns a formatter that outputs the content of the set as a single tag if possible, following ℂDuce syntax for patterns:- if
tis a singleton, it prints the atom as a tag, usingV.print - if
tis a an cofinite set in a single namespace, it prints the set asns:*wherensis the prefix to which the namespace is bound. - if
tisany, it prints_
In all cases above, the function returns
Some fwherefis the printer. Otherwise it returnsNone.- if