Module Cduce_types__AtomSet

Sets of atoms, used for variants (`nil, `true, `false, …) as well as for XML tags (<hello>[]<(`hello)>[]).

module V : sig ... end

A module for manipulating atom Values.

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
type elem

The type of the values in the set

The type of the set, with mandatory custom operations.

include Custom.T
type t
val dump : Stdlib.Format.formatter -> t -> unit
val check : t -> unit
val equal : t -> t -> bool
val hash : t -> int
val compare : t -> t -> int
val empty : t

The empty set

val any : t

The full set, containing all possible values for this kind.

val atom : elem -> t

atom e creates a singleton set containing element e.

Set operations :

val cup : t -> t -> t

cup t1 t2 returns the unions of t1 and t2.

val cap : t -> t -> t

cap t1 t2 returns the intersection of t1 and t2.

val diff : t -> t -> t

diff t1 t2 returns the set of elements of t1 not in t2.

val neg : t -> t

neg t returns the set diff any t.

module Infix : sig ... end

Type specific operations:

val any_in_ns : Ns.Uri.t -> t

any_in_ns uri returns the set of all atoms that have a particular namespace.

Membership:

val is_empty : t -> bool

is_empty t checks wheter t is the empty set.

val contains : V.t -> t -> bool

contains a t checks whether the atom a belongs to t

val single : t -> V.t

single t assumes t is a singleton and returns its unique element.

raises [Not_found]

if t is the empty set

raises [Exit]

if t contains more than one element

val disjoint : t -> t -> bool

disjoint t1 t2 checks whether t1 and t2 have an empty intersection.

type sample = (Ns.Uri.t * Ns.Label.t option) option

The type of a sample that is a representation of an element of the set.

val sample : t -> sample

sample t returns a sample for t for instance if t is any returns None. If t contains only co-finite sets for some namespaces ns1, ns2, … returns Some (ns1, None). Finaly, if t contains at least one element, sample t returns Some(ns, Some l) where ns is the namespace and l the local name.

raises [Not_found]

if t is empty.

val contains_sample : sample -> t -> bool

contains_sample s t checks whether the given sample represents an element of t.

Formatting functions :

val print : t -> (Stdlib.Format.formatter -> unit) list

print t returns, for each namespaces in the set t, 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) option

print_tag t returns a formatter that outputs the content of the set as a single tag if possible, following ℂDuce syntax for patterns:

  • if t is a singleton, it prints the atom as a tag, using V.print
  • if t is a an cofinite set in a single namespace, it prints the set as ns:* where ns is the prefix to which the namespace is bound.
  • if t is any, it prints _

In all cases above, the function returns Some f where f is the printer. Otherwise it returns None.