Learn

Contents

The playground on your computer

elucid8 playground is the playground in a window of its own on your computer (macOS, Windows and Linux), from release 0.26.0. Unlike the playground in your browser, it runs on your own data of any size and keeps every version in folders that elucid8 run works in as they are. Describe what you want to compute and the program is written for you, start from an example, or write it yourself; then ask for any value at any point and see why it came out as it did.

It comes with the elucid8 command: pip install elucid8, or download it from the Download page (how to open it). On Linux it opens with the desktop build, which needs WebKitGTK 4.1 (sudo apt install libwebkit2gtk-4.1-0 on Debian and Ubuntu); the install command and pip install elucid8 give you that build where it can run (Where it runs).

Starting it

elucid8 playground

The first time, it opens on a blank program, its name shown as New program in the top bar. Start in one of two ways:

  1. Describe what you want to compute: click the box at the top left, say it in plain words, for example "a running total of daily sales, and its 7-day average", and press Generate program (Shift-Cmd-Enter on macOS, Shift-Ctrl-Enter on Windows and Linux). The program is written for you and arrives in the editor, ready to run.
  2. Choose an example: Examples ▾, beside Generate program, lists 34 programs ready to run under their group headings, from The basics: a running total, step by step to A fraud check that can't wait: a deadline on a call, each with its data, its question and the description that writes it. Press one, or move to it with the arrow keys and press Enter. Choose The basics and the question reads Ask for total at t = 4; press Run query (or Enter in the coordinate box) and the answer says total[t = 4] is 14.

Then everything can be explored and changed: ask for any value, see its picture and Why?, edit the program, its data or the description. The Next: line under the answer says what to try next (Hints: on shows it; press it to hide it).

The window has a bar along its top: the program's name, New program, Open ▾, Settings and Help. Under it, on the left, are the description's box with Generate program and Examples ▾, then the Program and Data In/Out tabs, the editor, Update and the version line. On the right are the question (Ask for, the value, its coordinates and Run query), the answer with Why? beside it, and the Visualize and Trace tabs. Every part keeps its place from the first moment: what is not ready yet is greyed, with a line saying what will be there ("The answer will appear here."). In a narrow window, or at a larger text size, the two columns become one: the description, the question, its answer and its picture come first, and the program is below them; scroll the window to reach it.

To keep your work somewhere else, give the folder:

elucid8 playground --dir ~/work/elucid8

Your projects

Each program you make is a project, a folder of its own; everything is kept in the playground's folder:

eLucid8/
  projects/
    the-basics/
      program.el8      the program, as last updated
      deploy.json      where its data comes from, where its outputs go, and its question
      data/            its data files
      prompt.md        its description
      versions/        every version: 1/, 2/, 3/ …, each with the description it was made from
      out/             what its outputs write
  templates/           the examples, copied there the first time
cd ~/eLucid8/templates/the-basics && elucid8 run
{"name":"total","context":{"t":4},"outcome":{"kind":"value","value":14,"ts":0}}

Your data

To use your own data, copy the file into the project's data/ folder and name the input after the file: data/sales.csv is read by input("sales", t : 12). The Data In/Out tab lists the project's files, each with the input that reads it, and opens the one you choose in the editor under the list. A file of up to 10,000 lines and 1 MB can be changed there: press Update to apply the change as the next version ("your data changed") and ask your question again. A larger file is shown read-only, its first 200 lines, and is read whole when you ask.

Asking and seeing

Writing programs from a description

Describe what you want in the box at the top left and press Generate program: the program, with a check you can work out by hand, arrives in the editor as the next version, and the box keeps your description. The line under the box says how it went ("✓ Written and checked: …"), and In plain words ▸ opens what the program computes, in plain words. With a data file chosen in the Data In/Out tab, the writer is sent its columns and first rows too.

Generate program always writes the whole program anew from the description, so to change a program, change its description and generate it again. The version before stays: Undo brings it back, with its description. Changes in the editor that you had not applied are kept first as a draft. When nothing compiles, Open it anyway puts the last attempt in the editor with its error marked, to fix by hand.

An example's description writes that example's program: copy it into a blank program and press Generate program to see it written. These are answered with programs written for them earlier, so they need no key and cost nothing. (Right after you choose an example, Generate program is greyed: its program is there already. Change the description to generate another.)

This uses Anthropic's AI on your own account. Give your Anthropic API key once: in Settings, press Add key… and paste it (on macOS and Linux), or give it in a terminal:

elucid8 key set

Without a key, Generate program opens a note with Add key… in it; the examples work without one.

It is kept in a file only you can read (key in eLucid8's settings folder) and sent only to Anthropic, and the playground reads it only when you press Generate program. Settings says whether a key is set, and Remove deletes it. Once you have spent something, the line under Generate program says what you have spent since you opened the playground (a session). Spending is capped at $2 a session and $5 a day unless you change it:

elucid8 key limits --session 3 --day 10
elucid8 key status

While a program is being written, Esc stops it.

Help opens the playground's help: what it does and its keys.

Settings

Settings holds the playground's choices, one to a row:

The playground's own program

The playground is itself a program in eLucid8, built into the command. To read it, or to run a changed copy:

elucid8 playground --source my-playground
elucid8 playground --program my-playground

Is it safe to run? says what the playground can do on your computer, and the Command reference gives every option.