The Standard ML Basis Library


Overview

This section gives an overview of the organization of the SML Basis Library.

Top-level environment

The top-level environment consists of those type, exception, and value identifiers that can be used without qualification. These identifiers are called pervasive. For example, the unqualified type int is bound to the type Int.int and the function length is bound to List.length. In addition to the pervasive identifiers, the top-level environment also consists of overloaded identifiers (e.g., + and *) and infix definitions. The top-level environment is described in [Top-level environment].

Basic types

Operations of the various basic types (i.e., bool, int, word, and real) are all provided by the SML Basis Library. Additional support for computing with real numbers is provided by the Math and IEEEReal structures. In addition, implementations may implement multiple different precisions of integers, words, or reals.

Standard datatypes

The SML Basis Library provides support for basic operations on the standard option and list datatypes with the Option, List, ListPair structures.

Vectors and arrays

The SML Basis Library supports of mutable array and immutable vector types. In addition to the array and vector type constructors, there are a variety of monomorphic array and vector types. The monomorphic types provide a more compact representation at the cost of less polymorphism. The Library also defines slices of arrays and vectors, which are an abstraction of contiguous subsequences.

Text

Text processing is supported in the form three basic types: char, string, and substring. Strings are immutable vectors of characters and substrings are string slices (in fact, the types string is just another name for CharVector.vector and substring is another name for CharVectorSlice.slice). The SML Basis Library also provides functions for converting to and from basic types and strings.

Input/output

The SML Basis Library supports both binary and text input/output (I/O) using a three-level I/O stack. At the lowest level, the PRIM_IO interface provides unbuffered I/O on abstract readers and writers. The STREAM_IO interface provides buffering on top of the primitive readers and writers; it also provides a functional input model that supports arbitrary lookahead. The top-level of I/O support is the IMPERATIVE_IO interface, which supports dynamically bound streams (i.e., one can redirect an imperative I/O stream after it has been opened).

System interfaces

The SML Basis Library provides support for writing portable code that uses common systems services (e.g., directory navigation). The OS structure collects together support for file system operations (OS.FileSys), low-level I/O (OS.FileSys), pathnames (OS.Path), and process control (OS.Process). There is also support for time and date manipulations, as well as interval timing.

Sockets

Network programming using sockets is supported by a collection of optional structures. The Socket structure collects together the various operations for socket control and I/O. Three structures are provided for socket creation: INetSock for Internet-domain sockets, UnixSock for Unix-domain sockets, and GenericSock for arbitrary sockets. The NetHostDB, NetProtDB, and NetServDB structures provide access to the network database (e.g., for hostname lookup).

Unix-specific interfaces

The SML Basis Library supports access to additional system services on Unix systems via the optional Unix and Posix structures.

Microsoft Windows-specific interfaces

The SML Basis Library supports access to additional system services on Microsoft Microsoft Windows systems via the optional Windows structure.

Required components

For an implementation to be compliant with the SML Basis Library specification, it must provide all of the required components. Furthermore, these components must be implemented as defined by specification; extending these interfaces is not permitted.

Required signatures

The following table lists the signatures that every SML implementation is required to provide:


ARRAY
ARRAY_SLICE
BIN_IO
BOOL
BYTE
CHAR
COMMAND_LINE
DATE
GENERAL
IEEE_REAL
IMPERATIVE_IO
INTEGER
IO
LIST
LIST_PAIR
MATH
MONO_ARRAY
MONO_ARRAY_SLICE
MONO_VECTOR
MONO_VECTOR_SLICE
OPTION
OS
OS_FILE_SYS
OS_IO
OS_PATH
OS_PROCESS
PRIM_IO
REAL
STREAM_IO
STRING
STRING_CVT
SUBSTRING
TEXT
TEXT_IO
TEXT_STREAM_IO
TIME
TIMER
VECTOR
VECTOR_SLICE
WORD

Required structures

The following table lists the structures that every SML implementation is required to provide:


Array :> ARRAY
ArraySlice :> ARRAY_SLICE
BinIO :> BIN_IO
BinPrimIO :> PRIM_IO
Bool :> BOOL
Byte :> BYTE
CharArray :> MONO_ARRAY
CharArraySlice :> MONO_ARRAY_SLICE
Char :> CHAR
CharVector :> MONO_VECTOR
CharVectorSlice :> MONO_VECTOR_SLICE
CommandLine :> COMMAND_LINE
Date :> DATE
General :> GENERAL
IEEEReal :> IEEE_REAL
Int :> INTEGER
IO :> IO
LargeInt :> INTEGER
LargeReal :> REAL
LargeWord :> WORD
List :> LIST
ListPair :> LIST_PAIR
Math :> MATH
Option :> OPTION
OS :> OS
Position :> INTEGER
Real :> REAL
StringCvt :> STRING_CVT
String :> STRING
Substring :> SUBSTRING
TextIO :> TEXT_IO
TextPrimIO :> PRIM_IO
Text :> TEXT
Timer :> TIMER
Time :> TIME
VectorSlice :> VECTOR_SLICE
Vector :> VECTOR
Word8Array :> MONO_ARRAY
Word8ArraySlice :> MONO_ARRAY_SLICE
Word8Vector :> MONO_VECTOR
Word8VectorSlice :> MONO_VECTOR_SLICE
Word8 :> WORD
Word :> WORD

Optional components

In addition to the required components, an implementation may choose to provide some optional components. While these components are optional, if present, they must be implemented as defined by specification; extending these interfaces is not permitted.

Optional signatures

The following table lists the optional signatures that an SML implementation may choose to provide:


ARRAY2
BIT_FLAGS
GENERIC_SOCK
INET_SOCK
INT_INF
MONO_ARRAY2
NET_HOST_DB
NET_PROT_DB
NET_SERV_DB
PACK_REAL
PACK_WORD
POSIX
POSIX_ERROR
POSIX_FILE_SYS
POSIX_IO
POSIX_PROC_ENV
POSIX_PROCESS
POSIX_SIGNAL
POSIX_SYS_DB
POSIX_TTY
SOCKET
UNIX
UNIX_SOCK
WINDOWS

Optional structures

The following table lists the optional structures that an SML implementation may choose to provide:


Array2 :> ARRAY2
BoolArray :> MONO_ARRAY
BoolArray2 :> MONO_ARRAY2
BoolArraySlice :> MONO_ARRAY_SLICE
BoolVector :> MONO_VECTOR
BoolVectorSlice :> MONO_VECTOR_SLICE
CharArray2 :> MONO_ARRAY2
FixedInt :> INTEGER
GenericSock :> GENERIC_SOCK
INetSock :> INET_SOCK
IntArray :> MONO_ARRAY
IntArray2 :> MONO_ARRAY2
IntArraySlice :> MONO_ARRAY_SLICE
IntVector :> MONO_VECTOR
IntVectorSlice :> MONO_VECTOR_SLICE
Int<N>Array :> MONO_ARRAY
Int<N>Array2 :> MONO_ARRAY2
Int<N>ArraySlice :> MONO_ARRAY_SLICE
Int<N> :> INTEGER
Int<N>Vector :> MONO_VECTOR
Int<N>VectorSlice :> MONO_VECTOR_SLICE
IntInf :> INT_INF
NetHostDB :> NET_HOST_DB
NetProtDB :> NET_PROT_DB
NetServDB :> NET_SERV_DB
PackWord<N>Big :> PACK_WORD
PackWord<N>Little :> PACK_WORD
PackRealBig :> PACK_REAL
PackRealLittle :> PACK_REAL
PackReal<N>Big :> PACK_REAL
PackReal<N>Little :> PACK_REAL
Posix :> POSIX
RealArray2 :> MONO_ARRAY2
RealArray :> MONO_ARRAY
RealArraySlice :> MONO_ARRAY_SLICE
RealVector :> MONO_VECTOR
RealVectorSlice :> MONO_VECTOR_SLICE
Real<N>Array :> MONO_ARRAY
Real<N>Array2 :> MONO_ARRAY2
Real<N>ArraySlice :> MONO_ARRAY_SLICE
Real<N> :> REAL
Real<N>Vector :> MONO_VECTOR
Real<N>VectorSlice :> MONO_VECTOR_SLICE
Socket :> SOCKET
SysWord :> WORD
UnixSock :> UNIX_SOCK
Unix :> UNIX
WideCharArray :> MONO_ARRAY
WideCharArray2 :> MONO_ARRAY2
WideCharArraySlice :> MONO_ARRAY_SLICE
WideChar :> CHAR
WideCharVector :> MONO_VECTOR
WideCharVectorSlice :> MONO_VECTOR_SLICE
WideString :> STRING
WideSubstring :> SUBSTRING
WideTextPrimIO :> PRIM_IO
WideText :> TEXT
Windows :> WINDOWS
Word<N>Array :> MONO_ARRAY
Word<N>Array2 :> MONO_ARRAY2
Word<N>ArraySlice :> MONO_ARRAY_SLICE
Word<N>Vector :> MONO_VECTOR
Word<N>VectorSlice :> MONO_VECTOR_SLICE
Word<N> :> WORD

Optional functors

The following table lists the optional functors that an SML implementation may choose to provide:


ImperativeIO :> IMPERATIVE_IO
PrimIO :> PRIM_IO
StreamIO :> STREAM_IO


[ Top | Parent | Contents | Index | Root ]

Generated April 12, 2004
Last Modified July 18, 2002
Comments to John Reppy.


This document may be distributed freely over the internet as long as the copyright notice and license terms below are prominently displayed within every machine-readable copy.

Copyright © 2004 AT&T and Lucent Technologies. All rights reserved.

Permission is granted for internet users to make one paper copy for their own personal use. Further hardcopy reproduction is strictly prohibited. Permission to distribute the HTML document electronically on any medium other than the internet must be requested from the copyright holders by contacting the editors. Printed versions of the SML Basis Manual are available from Cambridge University Press. To order, please visit www.cup.org (North America) or www.cup.cam.ac.uk (outside North America).