Boxed bitwise-integer masks
===========================

Scheme48 provides a facility for generalized boxed bitwise-integer masks.  Masks represent sets of elements.  An element is any arbitrary object that represents an index into a bit mask; mask types are parameterized by an isomorphism between elements and their integer indices.  Usual abstract set operations are available on masks.  The mask facility is divided into two parts: the mask-types structure, which provides the operations on the generalized mask type descriptors; and the masks structure, for the operations on masks themselves.

Mask types
----------

 -- procedure: make-mask-type name elt? index->elt elt->index size returns mask-type
 -- procedure: mask-type? object returns boolean
 -- procedure: mask? object returns boolean
     Make-mask-type constructs a mask type with the given name. Elements of this mask type must satisfy the predicate ELT?. INTEGER->ELT is a unary procedure that maps bit mask indices to possible set elements; ELT->INTEGER maps possible set elements to bit mask indices.  SIZE is the number of possible elements of masks of the new type, ie the number of bits needed to represent the internal bit mask.  Mask? is the disjoint type predicate for mask objects.

 -- procedure: mask-type mask returns mask-type
 -- procedure: mask-has-type? mask type returns boolean
     Mask-type returns MASK's type.  Mask-has-type? returns #t if MASK's type is the mask type TYPE or #f if not.

The mask-types structure, not the masks structure, exports mask? and mask-has-type?: it is expected that programmers who implement mask types will define type predicates for masks of their type based on mask? and mask-has-type?, along with constructors etc for their masks.

 -- procedure: integer->mask type integer returns mask
 -- procedure: list->mask type elts returns mask
     Integer->mask returns a mask of type TYPE that contains all the possible elements E of the type TYPE such that the bit at E's index is set.  List->mask returns a mask whose type is TYPE containing all of the elements in the list ELTS.

Masks
-----

 -- procedure: mask->integer mask returns integer
 -- procedure: mask->list mask returns element-list
     Mask->integer returns the integer bit set that MASK uses to represent the element set.  Mask->list returns a list of all the elements that MASK contains.

 -- procedure: mask-member? mask elt returns boolean
 -- procedure: mask-set mask elt ... returns mask
 -- procedure: mask-clear mask elt ... returns mask
     Mask-member? returns true if ELT is a member of the mask MASK, or #f if not.  Mask-set returns a mask with all the elements in MASK as well as each ELT .... Mask-clear returns a mask with all the elements in MASK but with none of ELT ....

 -- procedure: mask-union mask1 mask2 ... returns mask
 -- procedure: mask-intersection mask1 mask2 ... returns mask
 -- procedure: mask-subtract maska maskb returns mask
 -- procedure: mask-negate mask returns mask
     Set operations on masks.  Mask-union returns a mask containing every element that is a member of any one of its arguments. Mask-intersection returns a mask containing every element that is a member of every one of its arguments.  Mask-subtract returns a mask of every element that is in MASKA but not also in MASKB.  Mask-negate returns a mask whose members are every possible element of MASK's type that is not in MASK.