Alice Project


________ Overview ____________________________________________________

The interactive top-level provides an interpreter-style environment that allows entering and evaluating programs from an interactive prompt. It can be run either as a text-based shell application or with a graphical user interface. The text-based interactive top-level is designed to work with the standard Emacs mode for SML. A patched version of that mode, modified to harmonize with Alice ML syntax extensions, is also available from the Alice download page.

________ Synopsis ____________________________________________________

alice [-g | --gui] [<input file> ...]

________ Description _________________________________________________

The interactive top-level provides an interpreter-like read-eval-print loop. In both, text mode and graphical mode, the system will - after preloading some components, show a prompt for its interactive session. It allows entering arbitrary Alice components. Input can stretch several lines, it is terminated by a line containing a semicolon as its last character. The system will print the results and inferred types for the given declarations, or an appropriate error message.

Nested and aggregated data structures are only printed up to certain depth and width limits. These can be controlled using the respective references from the Print module.

Values of abstract type are not printed. The register function from the Print module can be used to install simple user-defined printing functions for abstract types that the top-level will use in its outputs.

Values of abstract type are not printed. The register function from the Print module can be used to install simple user-defined printing functions for abstract types that the top-level will use in its outputs.

Note that the inspect function from the Inspector is available to browse complex results conveniently.


Like in other SML systems, there also is the special purpose function

use : string -> unit

which, given the name of an Alice source file, will process this file as if it had been fed as direct input.


Each input in the interactive top-level actually is a component. This implies that import announcements can be entered to link in separately compiled components from arbitrary URIs:

- import structure Foo from "";
### loaded signature from
structure Foo : FOO = Foo

For convenience, it is possible to abbreviate import announcements as follows in the interactive top-level:

- import "";
### loaded signature from
structure Foo : FOO = Foo

Such an announcement will import all items exported by the corresponding component.

________ Text interface ______________________________________________

In text mode, a computation can be interrupted using Ctrl-C (the Posix signal SIGINT).

A running computation can also be put into background using Ctrl-Z (the Posix signal SIGTSTP, Ctrl-Break on Windows), getting you back to the prompt. The computation will proceed concurrently. Intuitively, the effect is roughly as if the initial input had been prefixed with spawn. However, it works for arbitrary inputs, particularly declarations.

An interactive session can be terminated by typing an end-of-file character (Ctrl-D on Unix systems, Ctrl-Z on Windows systems). Alternatively, the global function exit may be called.

Note: Depending on the shell used, the Ctrl sequences described above may not work as expected under Windows. We recommend using either zsh under Cygwin, or the SML mode for Emacs. A plain Windows command shell will also work. Bash and particularly tcsh are known to be problematic with respect to signal handling. Alternatively, you might use the graphical mode.

A session can be reset by applying the global funciton reset (note that this does not kill any running threads).

________ Graphical interface _________________________________________

When started with the command line option -g (or --gui), the interactive top-level comes with a graphical user interface (this is the default when Alice is started from the system's graphical interface - e.g. the Start menu - instead of a shell). The graphical interface not only incorporates the input-eval-print window, but also an Alice ML program editor. Most of the interface is standard editor functionality and should be self-explanatory. We only describe the Alice specific features here.

The window is split into three panes (two intially):

With Ctrl-1, Ctrl-2, and Ctrl-3 the input focus can be moved quickly between the three panes. The panes can be resized by mouse.


The interaction pane operates much like the interactive top-level in text mode: ML snippets can be entered that can span several lines and must be terminated by semicolon. In addition, previous inputs can be retrieved via the history commands from the Eval menu (or the shortcuts Ctrl-Up and Ctrl-Down). History is saved when the top-level is quit.

The Interrupt and Background commands from the Eval menu allow aborting the current computation or putting it into background. The whole interpreter environment can be reset from the menu, or by invoking reset() (note that this does not kill any running threads).


The Eval menu allows feeding portions of an editor window into the interactive session. This works in three ways:

Note that unlike direct input, fed input is not required to be terminated by a semicolon.

When input has been fed from a buffer, and an error occured, then selecting Jump to Error (Ctrl-E) from the Edit menu will immediately move the focus to the respective error location and select it.


By selecting Compile (Ctrl-K) from the File menu, the currently edited file can be compiled to a stand-alone component on disk. Eventual error messages will be printed on the interaction pane. Like with feeding, Jump-to-Error can be used to select the error region in case of an error.

Type information

When feeding or compiling a buffer, the compiler collects type information about all identifiers found in the program (including type, module, or signature identifiers). This information will subsequently be displayed in the status bar whenever the cursor is positioned on an identifier in the respective buffer. In case that the information does not fit the single line of the status bar, the full information can be seen in a tooltip by moving the mouse pointer over the status bar.

Note that partial type information is available even if compilation failed with a type error - all types derived so far are displayed. However, compilation or feeding erases all previous type information about the buffer.

Session Management

The GUI provides for simple session management: on startup, previously open files are re-opened, and the input history for the interaction pane is restored.

If "-" is given as a pseudo file name among the <input files> on the command line, then loading of files from the previous session is suppressed. Session reloading also can be deactivated altogether in the preferences.

________ Options _____________________________________________________

-v, --version

Print compiler version.

-?, -h, --help

Print usage information.

-g, --gui

Run with graphical user interface.

________ Environment variables _______________________________________

The interactive top-level is parameterized by the same environment variables as the batch compiler.

last modified 2005/09/03 11:30