The Universal structure provides a universal union type. It allows value of any type to be stored in a single table without knowing in advance the types to be stored. Note that this is not the same as a dynamic type. The values are discriminated by the tag, not by the type. There may be more than one tag that can be used with values of a particular type and these are treated as completely different. Universal is built in for efficiency reasons but it is perfectly feasible to implement it in Standard ML using exception bindings.
structure Universal: sig type universal type 'a tag val tag: unit -> 'a tag val tagInject: 'a tag -> 'a -> universal val tagIs: 'a tag -> universal -> bool val tagProject: 'a tag -> universal -> 'a end
Inject a value into the union. This marks the value with the tag.