Using the Ciao Prolog Playground
The Ciao Prolog Playground includes a number of areas, most of which are editable (note that the arrangement of the areas is configurable):
- The editor area (left area, or top if the window is narrow) is an editor for the program or notebook-style document. Users can add their code into this editor and modify it there. Programs can be loaded into the system's top level (see below), where they can be run by entering queries at the prompt. Documents are processed in the top level and rendered in the preview area (see below). If the document contains runnable examples these can be executed there.
- The top-level area (on the right, or bottom if the window is narrow) is where most communication with the system takes place. The top-level first shows Loading Ciao... while the system is loading its dependencies. When the top-level is completely ready to use, it will show the prompt ?- . Now programs can be loaded and queries issued. This area is also an editor that allows, e.g., editing the query, recalling previous queries, etc.
- The preview area is where documents or program documentation is rendered. This preview area (and other areas) can be also used for other graphical program output.
Additionally
In addition, in the More... pull-down the following can be selected:
- Run tests (Ctrl-c + u)
- Loads the unit test library (unittest) into the top-level and runs any unit tests (test assertions) that may appear in the code.
- Analyze and check assertions (Ctrl-c + V)
- Analyze the program and perform compile-time checking of the assertions (types, modes, determinacy, ...) in the current module (using CiaoPP).
- Analyze and check assertions (w/output)
- Same as above, but also show in a separate area the results of analysis, i.e., the program annotated with the analysis results.
- Specialize code (Ctrl-c + O)
- Run the CiaoPP specializer (partial evaluator) on the code in the editor area.
- Browse analysis/checking/optimizing options
- Open the CiaoPP graphical menu for selecting different options for analysis, assertion checking, and optimization.
Key bindings
The playground supports a number of key bindings (including some of the most used in Emacs). They are listed below, classified by functionality.
Editing key bindings
These commands and bindings are useful for editing and moving around in the editor area, top levels, etc.:
- Ctrl-a - move cursor to the beginning of the line.
- Ctrl-e - move cursor the end of the line.
- Ctrl-f - move cursor forward.
- Ctrl-b - move cursor backward.
- Ctrl-p - previous line.
- Ctrl-n - next line.
- Ctrl-s - search forward in the editor.
- Ctrl-r - search backward in the editor.
- Ctrl-d - delete character to the right.
- Ctrl-h - delete character to the left.
- Ctrl-k - kill the line after the cursor.
- Ctrl-m - insert line below.
- Ctrl-o - insert line after the current position.
- Ctrl-z - undo.
- Ctrl-g - go to line.
- Ctrl-x + u - undo.
- Ctrl-X + o - move to another playground area.
- Ctrl-v - go to the end of the editor.
- Ctrl-x + Ctrl-p - select all.
- Ctrl-x + Ctrl-u - transform selected text to upper case.
- Ctrl-x + Ctrl-l - transform selected text to lower case.
- Esc + d - delete the next word.
- Esc + v - move cursor to the beginning.
- Esc + Backspace - delete word to the left.
- Esc + ; - comment/uncomment current line or selected lines.
Code processing key bindings
These commands perform Ciao or filesystem-related actions:
- Ctrl-x + Ctrl-s - save file (same as button).
- Ctrl-c + l - load code into top-level (same as button).
These commands perform actions on the source code:
- Ctrl-c + d - (un)debug source code (same as button).
- Ctrl-c + D - preview documentation (same as button).
- Ctrl-c + u - run any tests in the source code (same as menu).
- Ctrl-c + V - analyze and check assertions in source code (same as menu).
- Ctrl-c + O - run specializer on source code (same as menu).
Specific key bindings for the top-level
The top-level area includes some key bindings of its own:
- Up arrow - previous query in history.
- Down arrow - next query in history.
- Ctrl-p - previous query in history.
- Ctrl-n - next query in history.
- Ctrl-c - abort current query, if there is any running.
Ctrl-c fully terminates the Ciao worker executing the Ciao process in the browser, so it may take some time to reload dependencies after aborting. The code present in the left (or top) window will be reloaded to the top-level.
Some playground characteristics and current limitations
In this platform the Ciao system code (binaries) and libraries are downloaded into your browser and all code is executed locally. This has the advantage that no connection is required other than this initial download, no server is necessary, etc. Also note that with this approach no information about your code or document will be uploaded or gathered.
Please also be aware of some current limitations of the playground with respect to a full, native installation of the Ciao system:
- To reduce download times, only a subset of the libraries are loaded by default.
- Currently this platform is limited to 32-bit binaries, runs around 2-3x slower than native binaries, and only offers partial POSIX features. Some Prolog libraries that depend on 3rd-party binaries (via the foreign interface) may not be currently available.
- The top level currently has some limitations regarding the loading of packages, portraying answers, and others. We are actively working on all of these and are adding functionality continuously.
- Reading input from standard input (read/1) is currently not directly supported, due to WebAssembly limitations. We also plan to fix this soon.
- To save space, only a subset of the analyses (abstract domains) and the capabilities of CiaoPP for program verification (assertion checking, etc.) and optimization are currently available.
Please ask us if some useful library or feature is missing; if technically possible, we will add it. In any case, for intensive use we recommend installing Ciao Prolog natively, for improved performance and full features.