The PolyML.NameSpace structure contains functions associated with a name-space, a collection of values, types, structures, functors, signatures and infix settings. It is used primarily in connection with the compiler.
In the Standard ML language there are separate classes of identifiers for values, type constructors, structures, signatures and functors. In addition infix status is essentially another identifier class since infix status and priority can be set for an identifier whether or not there is actually a function with that name. Value identifiers include datatype and exception constructors as well as identifiers bound with val or fun bindings. Name-spaces are ways of holding and managing collections of identifiers. Nothing in the NameSpace structure assumes a particular implementation of a name-space; it is more of an interface than an implementation.
structure NameSpace: sig type typeVal type valueVal type fixityVal type functorVal type signatureVal type structureVal val displayVal: valueVal * int * nameSpace -> pretty val displayType: typeVal * int * nameSpace -> pretty val displayFix: string * fixityVal -> pretty val displayFunct: functorVal * int * nameSpace -> pretty val displaySig: signatureVal * int * nameSpace -> pretty val displayStruct: structureVal * int * nameSpace -> pretty val codeForFunct: functorVal -> CodeTree.codetree val codeForStruct: structureVal -> CodeTree.codetree val codeForValue: valueVal -> CodeTree.codetree type nameSpace = {allFix: unit -> (string * fixityVal) list, allFunct: unit -> (string * functorVal) list, allSig: unit -> (string * signatureVal) list, allStruct: unit -> (string * structureVal) list, allType: unit -> (string * typeVal) list, allVal: unit -> (string * valueVal) list, enterFix: string * fixityVal -> unit, enterFunct: string * functorVal -> unit, enterSig: string * signatureVal -> unit, enterStruct: string * structureVal -> unit, enterType: string * typeVal -> unit, enterVal: string * valueVal -> unit, lookupFix: string -> fixityVal option, lookupFunct: string -> functorVal option, lookupSig: string -> signatureVal option, lookupStruct: string -> structureVal option, lookupType: string -> typeVal option, lookupVal: string -> valueVal option} type typeExpression val displayTypeExpression: typeExpression * int * nameSpace -> pretty end val globalNameSpace: nameSpace
type nameSpace = { allFix: unit -> (string * fixityVal) list, allFunct: unit -> (string * functorVal) list, allSig: unit -> (string * signatureVal) list, allStruct: unit -> (string * structureVal) list, allType: unit -> (string * typeVal) list, allVal: unit -> (string * valueVal) list, enterFix: string * fixityVal -> unit, enterFunct: string * functorVal -> unit, enterSig: string * signatureVal -> unit, enterStruct: string * structureVal -> unit, enterType: string * typeVal -> unit, enterVal: string * valueVal -> unit, lookupFix: string -> fixityVal option, lookupFunct: string -> functorVal option, lookupSig: string -> signatureVal option, lookupStruct: string -> structureVal option, lookupType: string -> typeVal option, lookupVal: string -> valueVal option }
The nameSpace type is a record of functions. For each class of identifier there is a lookup function that takes a string and returns an option type, an enter function that takes a string name and adds a values to the table and an "all" function that returns a list of all the identifiers of that class. It is important to note that the nameSpace type does not imply any particular implementation, it is simply an interface. Typically, it will be implemented in terms of one or more hash-tables but it is perfectly possible to implement something more complex. For example, PolyML.make, is implemented by passing to the compiler a name-space that has a side-effect of checking, and if necessary recompiling, a file when called to look-up a structure, functor or signature.
val globalNameSpace: nameSpace
globalNameSpace is the default name-space. The interactive top-level, the use function and PolyML.make, all use this.
type valueVal type typeVal type fixityVal type functorVal type signatureVal type structureVal
type typeExpression
typeExpression is used to represent the type of a value. This is not really part of a name-space but is included here, along with displayTypeExpression as a convenience. Values of this type are returned as PTtype nodes in the parse-tree.
val displayVal: valueVal * int * nameSpace -> pretty
The displayVal function returns a text representation of the value as a pretty structure. The structure returned is similar to way values are printed at the top level and include both their value and their type. The int argument controls the depth when printing complex values. The nameSpace argument is used to assist in displaying appropriate type constructors in the type.