The interactive system mosml is invoked simply by typing mosml at the command line:
The interactive system can be terminated by typing quit(); and newline, or control-D (under Unix) or control-Z and newline (under DOS). Type `help "";' for help on built-in functions.
Invoking the interactive system with command line arguments
is equivalent to invoking mosml and, when Moscow ML has started, entering
In a mosml session, you may type help "lib"; for an overview of built-in function libraries. To get help on a particular identifier, such as fromString, type
This will produce a menu of all library structures which contain the identifier fromstring (disregarding the lowercase/uppercase distinction):
Choosing a number from this menu will invoke the help browser on the desired structure, e.g. Int. The help browser is primitive but easy to use. It works best with a window size of 24 lines.
The texts accessed by help are found in directory mosml/lib. For instance, all List functions are described in file mosml/lib/List.sig.
mosml\utility\dosedit
for instructions. You will not need to
quit the mosml session to edit a source file, and the script
will automatically reload the newly edited file.
Specify the default directories to be searched by use, compile and load. A call to use, compile or load will first search the current directory, then all directories specified by option `-I' in order of appearance from left to right, and finally the standard library directory.
Specify that the type checker should use `value polymorphism'; see Section 7. The default.
Specify that the type checker should distinguish imperative and applicative type variables, generalize all applicative type variables, and generalize imperative type variables only in non-expansive expressions. See Section 7.
Determines which library units will be included and open at compile-time, and which library units will be linked in at link-time:
Additional library units can loaded into the interactive system by using the load function; see Section 3.4 below.
Specify the standard library directory to be stdlib-directory. The
default standard library is usually mosml/lib under Unix and
c:\mosml\lib
under DOS.
The following non-standard primitives are defined in unit Meta, loaded (and open by default) only in the interactive system. Hence these primitives cannot be used from source files which are compiled separately. The functions compile and load deal with Moscow ML compilation units; see Section 4.
printVal is a polymorphic function provided as a quick debugging aid. This is an identity function, which as a side-effect prints its argument to standard output exactly as it would be printed at top-level. Output is flushed immediately. For printing strings, the function print is probably more useful than printVal.
This variable determines the depth (in terms of nested constructors, records, tuples, lists, and vectors) to which values are printed by the top-level value printer and the function printVal. The components of the value whose depth is greater than printDepth are printed as `#'. The initial value of printDepth is 20. This value can be changed by the user's program at any moment.
This variable determines the way in which list values are printed by the top-level value printer and the function printVal. If the length of a list is greater than printLength, only the first printLength elements are printed, and the remaining elements are printed as `...'. The initial value of printLength is 200. This value can be changed by the user's program at any moment.
Evaluating quit() quits Moscow ML immediately.
Evaluating installPP pp installs the prettyprinter pp at type ty, provided pp has type ppstream -> ty -> unit. The type ty must be a nullary (parameter-less) type constructor representing a datatype, either built-in (such as bool) or user-defined. Whenever a value of type ty is about to be printed by the interactive system, and whenever function printVal is invoked on an argument of type ty, the prettyprinter pp will be invoked to print it.
The prettyprinter pp must not call the flush_ppstream
function. See library unit PP for more information on
prettyprinters.
Evaluating use "f" causes ML declarations to be read from file f as if they were entered from the console. A file loaded by use may, in turn, evaluate calls to use. For best results, use use only at top level, or at top level within a use'd file.
Evaluating compile "U.sig" will compile and elaborate the unit signature in file U.sig, producing a compiled signature file U.ui. During compilation, the compiled signatures of other units will be accessed if they are mentioned in U.sig.
Evaluating compile "U.sml" will elaborate and compile the unit body in file U.sml, producing a bytecode file U.uo. If there is an explicit signature U.sig, then file U.ui must exist, and the unit body must match the signature. If there is no U.sig, then an inferred signature file U.ui will be produced also. No evaluation takes place. During compilation, the compiled signatures of other units will be accessed if they are mentioned in U.sml.
The declared identifiers will be reported if verbose is true (see below); otherwise compilation will be silent. In any case, compilation warnings are reported, and compilation errors abort the compilation and raise the exception Fail with a string argument.
Evaluating load "U" will load and evaluate the compiled unit body from file U.uo. The resulting values are not reported, but exceptions are reported, and cause evaluation and loading to stop. If U is already loaded, then load "U" has no effect. If any other unit is mentioned by U but not yet loaded, then it will be loaded automatically before U.
After loading a unit, it can be opened with open U. Opening it at top-level will list the identifiers declared in the unit.
When loading U, it is checked that the signatures of units mentioned by U agree with the signatures used when compiling U, and it is checked that the signature of U has not been modified since U was compiled; these checks are necessary for type safety. The exception Fail is raised if the signature checks fail, or if the file containing U or a unit mentioned by U does not exist.
Evaluating loadOne "U" is similar to load " U", but raises exception Fail if U is already loaded or if some unit mentioned by U is not yet loaded. That is, it does not automatically load any units mentioned by U. It performs the same signature checks as load.
Returns a name for the exception constructor in the exception. Never raises an exception itself. The name returned may be that of any exception constructor aliasing with exn. For instance, let exception E1; exception E2 = E1 in exnName E2 end may evaluate to "E1" or "E2".
Formats and returns a message corresponding to the exception. For the exceptions defined in the SML Basis Library, the message will include the argument carried by the exception.
Determines whether the signature inferred by a call to compile will be printed. The printed signature follows the syntax of Moscow ML signatures, so the output of compile "U.sml" can be edited to subsequently create file U.sig. The default value is false.
Determines whether quotations and antiquotations are permitted in declarations entered at top-level and in files compiled with compile; see Section 8 for a brief explanation. When quotation is false (the default), the backquote character is an ordinary symbol which can be used in ML symbolic identifiers. When quotation is true, the backquote character is illegal in symbolic identifiers, and a quotation `a b c` will be evaluated to an object of type 'a frag list.
Determines whether the type checker should use `value polymorphism'; see Section 7. Command-line option -valuepoly sets valuepoly to true (the default), whereas option -imptypes sets valuepoly to false; see Sections 3.3 and 5.2.
Evaluating system "com" causes the command com to be executed by the operating system. If a non-zero integer is returned, this must indicate that the operating system has failed to execute the command. Under MS DOS, the integer returned always equals 0.