Using the Ciao Prolog Playground

The Ciao Prolog Playground includes two main areas, which are both editable (note that the arrangement of the areas is configurable):

  • The left area (or top area, if the window is narrow) is an editor for the program. Users can add their code into this editor and modify it there. The program can then be loaded into the system's top level, in the right area, where it can be run by entering queries at the prompt.

  • The right area (or bottom area, if the window is narrow) hosts the top-level, 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.

There is also a preview area for graphical program output.


Erases all previous content from the editor.

Lets you upload your own Prolog code from your local filesytem. This action also erases all previous content present in the editor.

Allows downloading the code written in the playground directly to your filesystem.

Loads the code in the editor into the top-level. It compiles it and, in case there are any errors, they are printed in the right (bottom) editor and highlighted in the left (top) one. Once you click this button, you can ask queries about your code in the top-level.

Run tests
Loads the unit test library (unittest) into the top-level and runs any unit tests (test assertions) that may appear in the code.

Is an alternative form of save: it copies into the clipboard a link that allows opening the playground with the current state of the program loaded in the editor area.

Abort query
This button will appear below the top-level when running a query that is taking too long. It terminates the query currently running.

This button fully terminates the Ciao worker executing the Ciao process, so it may take a some time to reload dependencies after aborting. The code in the editor area will be reloaded into the top-level.

Debug (or stop debugging) source and enable tracing the control flow of the program for the next queries (see debugger documentation for more information).

Preview documentation
Generate and preview the documentation for the current module (using LPdoc).

Analyze and check assertions
Analyze the program and perform compile-time checking of the assertions (types, modes, determinacy, ...) in the current module (using CiaoPP).

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 are useful to edit and move around the editor areas:

  • 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 - select the other editor.
  • 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 left word.
  • Esc + ; - comment/uncomment current line.

Loading 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).
  • Ctrl-C + U - run tests in current module (same as button).

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.

Current playground limitations

Please be aware of some current limitations of the playground with respect to a full, native installation:

  • Binaries and libraries are downloaded into your browser and code is executed locally (no connection required once loaded, no information about your code is gathered). To reduce download times, only some essential 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, debugging, portraying answers, and others. We are actively working on all of these and will be adding this functionality shortly.

  • Reading input from standard input (read/1) is currently not directly supported, due to WebAssembly limitations. We plan also to fix this soon.

Please ask us if some useful library or feature is missing; if technically possible, we will add it. However, for intensive use we recommend installing Ciao Prolog natively, for improved performance and full features.