Standard Basis Library for Poly/ML

The documentation for the Standard Basis Library is believed to being prepared for publication.  This is a short overview with specific reference to the implementation in Poly/ML.

General : GENERAL
Mainly standard exceptions.  All of the values in the General structure are available unqualified at the top level.

Option : OPTION
The option type, defined as datatype 'a option = NONE | SOME of 'a, together with associated functions.  Some of these are available unqualified at the top level.

SML90 : SML90
Various functions which were previously in the basis for ML90.

Bool : BOOL
Functions on type bool.

Int : INTEGER
LargeInt : INTEGER
Position : INTEGER
IntInf : INT_INF

Int, LargeInt and Position are the same structure and provide operations on type int.  In Poly/ML that is an arbitrary precision integer.   Poly/ML does not support any fixed precision integers.  IntInf provides additional functions, such as logical operations on integers.

Real : REAL
LargeReal : REAL

Real and LargeReal are the same structure in Poly/ML.  They provide functions on type real.

Math : MATH
The mathematical functions on type real.

IEEEReal : IEEE_REAL
Functions to manipulate IEEE real numbers, such as controlling rounding and handling not-a-number.

Word : WORD
Word8 : WORD
LargeWord : WORD
SysWord : WORD

Operations on machine words treated as unsigned quantities.  Functions which would overflow simply wrap round.  Poly/ML implements Word.word as 31 bit quantity on the i386 and PPC and a 30 bit quantity on the Sparc.  LargeWord and SysWord implement a double precision version used in the Windows and Posix structures.  Word8.word is an unsigned byte.

Char : CHAR
Operations on values of type char.

String : STRING
Operations on values of type string.

StringCvt : STRING_CVT
Additional string functions used primarily when converting between strings and string representations.

Substring : SUBSTRING
Operations on substrings.  These are segments of strings defined by a base string, an offset and a length and are designed to allow substrings to be manipulated without the storage overhead of creating the substrings themselves.

List : LIST
ListPair : LIST_PAIR

Functions on lists and lists of pairs.

Vector : VECTOR
Array : ARRAY

Polymorphic vector and array.

Word8Vector : MONO_VECTOR
CharVector : MONO_VECTOR
BoolVector : MONO_VECTOR
IntVector : MONO_VECTOR
RealVector : MONO_VECTOR
Word8Array : MONO_ARRAY
CharArray : MONO_ARRAY
WideCharArray : MONO_ARRAY
BoolArray : MONO_ARRAY
IntArray : MONO_ARRAY
RealArray : MONO_ARRAY

Monomorphic vectors and arrays.  Generally these are designed to be storage-efficient at the expense of time.  CharVector.vector is the same as string so provides vector operations on strings.  Word8Vector.vector is used in various places throughout the library as a binary analogue of string.  BoolVector and BoolArray use single bits for each value.

Array2 : ARRAY2
Word8Array2 : MONO_ARRAY2
CharArray2 : MONO_ARRAY2
BoolArray2 : MONO_ARRAY2
IntArray2 : MONO_ARRAY2
RealArray2 : MONO_ARRAY2

Two dimensional arrays.

Byte : BYTE
Provides functions to convert between characters and Word8.word values and between strings and Word8Vector.vector values.  In Poly/ML these can generally be implemented as a cast.

CommandLine : COMMAND_LINE
Access to the command line and arguments.  In Poly/ML this is the user arguments following the '--' argument.

Time : TIME
Functions on times.  Poly/ML implements this as microseconds since 1st January 1970 in Unix and nanoseconds since 1st January 1601 (FILETIME) in Windows.

Date : DATE
Functions on dates including conversions to and from Time.time.

Timer : TIMER
Functions to return CPU time and garbage collection time.


Pack8Big : PACK_WORD
Pack8Little : PACK_WORD
Pack16Big : PACK_WORD
Pack16Little : PACK_WORD
Pack32Big : PACK_WORD
Pack32Little : PACK_WORD
PackRealBig : PACK_REAL
PackRealLittle : PACK_REAL

Operations to pack and unpack integers and reals into byte vectors.

IO : IO
The IO structure contains types and exceptions used within the other IO structures.

TextIO : sig ... end
The TextIO structure is the top level of the IO stack for textual input and output.   This is level likely to be used most often.  Input and output are side-effecting and, if necessary, characters such as newlines are translated between the ML and operating system codes.
TextIO.StreamIO: TEXT_STREAM_IO
This substructure access to a lower level of textual input and output.  Output is not significantly different from that of TextIO but input is applicative rather than imperative.  In essence this means that input functions return both a value, character or string, and a new stream.  Reading from the new stream continues the input, reading from the original stream returns the previous value.  This is intended to simplify backtracking in parsing and works particularly well with the scan functions in the library.

BinIO : BIN_IO
BinIO is similar to TextIO but for binary input and output.  While TextIO works on types char and string, BinIO works on bytes (Word8.word) and byte vectors (Word8Vector.vector).  Unlike TextIO binary I/O does not perform any translation of characters.
BinIO.StreamIO: STREAM_IO
Similar to TextIO.StreamIO.

BinPrimIO : PRIM_IO
TextPrimIO : PRIM_IO
The primitive I/O functions are the lowest level of the stack.  They provide access to the underlying readers and writers.

ImperativeIO ( ... ) : IMPERATIVE_IO
StreamIO ( ... ) : STREAM_IO
PrimIO ( ... ) : PRIM_IO

These functors can be used to build new stacks to provide input and output on data structures other than characters and bytes.

OS : OS
The OS structure contains a large number of functions for accessing operating system facilities.  Most of them are grouped into substructures.  OS.FileSys contains functions for examining directories and files.  OS.Path operates on file path names.   OS.Process provides functions to terminate the current ML program with various results, examine the environment and to run sub-processes.  OS.IO provides the ability to poll a set of file descriptors.

Socket : SOCKET
Operations on sockets, providing access to network facilities from ML.  Socket does not actually contain functions to create sockets.  Instead these are found in the INetSock, UnixSock and GenericSock structures.

INetSock : INET_SOCK
Creates internet domain sockets and provides functions on internet addresses.

UnixSock : UNIX_SOCK
Creates Unix domain (local) sockets.  This structure is not provided in the Windows implementation.

GenericSock : GENERIC_SOCK
Can be used to create sockets in any domain supported by the system.

NetHostDB : NET_HOST_DB
NetDB : NET_DB
NetProtDB : NET_PROT_DB
NetServDB : NET_SERV_DB

Look up names in various tables.  NetHostDB looks up an internet address using DNS.   NetDB looks up a network in (on Unix) /etc/networks.  NetProtDB looks up a protocol in (on Unix) /etc/protocols.  NetServDB looks up a service in (on Unix) /etc/services.

Unix : UNIX
Provides access to Unix-specific functions, such as forking a process.  This structure is not provided in the Windows implementation.

Posix : POSIX
Provides access to a wide range of Unix system calls. This structure is not provided in the Windows implementation.

Windows : WINDOWS
Windows-specific functions.  This structure is not provided in the Unix implementations.

Last updated: 15 January 2002 by David Matthews.