General structure
May 20, 2026 ยท View on GitHub
The General structure provides the fundamental types unit, exn,
and order, the standard exceptions raised by the runtime, and a few
utility functions. Its contents are available without qualification in
every Morel program.
Specified by the Standard ML Basis Library.
Synopsis
type unit type exn = exn datatype order = LESS | EQUAL | GREATER exception Bind exception Match exception Chr exception Div exception Domain exception Fail of string exception Overflow exception Size exception Span exception Subscript val exnName : exn -> string val exnMessage : exn -> string val o : ('b -> 'c) * ('a -> 'b) -> 'a -> 'c val before : 'a * unit -> 'a val ignore : 'a -> unit val ! : 'a ref -> 'a val := : 'a ref * 'a -> unit
type unit
is the type that contains the single value (). It is used as the
result type of functions called for side effects.
type exn
is the type of exceptions. Every exception constructor creates a value
of this type, and the raise and handle constructs operate on it.
datatype order
exception Bind
is raised when pattern matching fails in a val binding.
exception Match
is raised when pattern matching fails in a case expression or
function application.
exception Chr
is raised by Char.chr when given an integer outside the valid range.
exception Div
is raised on integer division by zero.
exception Domain
is raised when a function is applied outside its domain.
exception Fail
is a general-purpose exception carrying a descriptive message string.
exception Overflow
is raised when an integer arithmetic result is too large to represent.
exception Size
is raised when a size argument is negative or exceeds the maximum allowed.
exception Span
is raised when an invalid source span is supplied.
exception Subscript
is raised when a sequence index is out of bounds.
exnName
exnName ex returns a name for the exception ex. The name returned may be that
of any exception constructor aliasing with ex. For instance,
let exception E1; exception E2 = E1 in exnName E2 end
might evaluate to "E1" or "E2".
exnMessage
exnMessage ex returns a message corresponding to exception ex. The precise format
of the message may vary between implementations and locales, but will
at least contain the string exnName ex.
Example:
exnMessage Div = "Div"
exnMessage (OS.SysErr ("No such file", NONE)) =
"OS.SysErr "No such file""
o
f o g is the function composition of f and g. Thus, (f o g) a
is equivalent to f (g a).
before
a before b returns a. It provides a notational shorthand for evaluating a,
then b, before returning the value of a.
ignore
ignore x always returns unit. The function evaluates its argument
but throws away the value.
!
``
Not yet implemented.