Prism
GuideCookbookExamplesErrorsPlayground

Guide

01Lessons & Slides02Exercises03Scene & State04Objects05Three dimensions06Controls07Timeline08Loops & Logic09Expressions & Math

Mathly Engine

Prism

A language for interactive math lessons.

Prism compiles to the IR that powers Mathly's interactive lesson engine. The compiler runs at seed-time or on the server, and its output is validated data — it never executes code, so it is safe to compile AI-generated source.

Start reading →Open playgroundCookbook

The guide

01

Lessons & Slides

A Prism file is either a bare scene { ... } (one visualization) or a lesson { ... } (a full multi-slide lesson). A slide is a composition: any prose, at most one scene, at most one exercise, and any number of goals — in any order. There is no "text slide" vs "quiz slide"; you just include the parts you need.

5 keywords
02

Exercises

An exercise is the checkable part of a slide — the thing the learner answers. Every exercise shares four optional lines: ask "..." (the prompt), hint "..." (repeatable — a hint ladder), ! "..." (the explanation shown after checking), and skill: "..." (the skill it tests).

10 keywords
03

Scene & State

A Prism file is exactly one scene <type> { ... } block. Everything else — space config, state, objects, controls, timeline — lives inside it.

4 keywords
04

Objects

Objects are the visual elements of a scene. Properties go in a trailing { key: value } block — omit it entirely if the object needs no configuration. All objects accept: color, style (solid/dashed/dotted), show:<expr>, width:<number>. Note: curve, line, rect, circle, polygon, vector, arc, image require plane scenes; only point and label work on numberline scenes.

11 keywords
05

Three dimensions

A scene space3 draws in 3D. It needs a z: [min, max] alongside x and y, and it projects orthographically the way a textbook draws a solid — no perspective, so parallel edges stay parallel and lengths along an axis stay comparable. Axes, arrowheads and unit ticks are drawn for you. Point the camera: at a param and the learner can spin the figure, which is the only reliable way to resolve what is in front of what. The 3D objects below are only legal inside a space3 scene, and the 2D ones (curve, rect, circle, ...) are not.

6 keywords
06

Controls

Controls are the interactive widgets the learner uses. They write to state variables, which re-evaluates all object expressions.

5 keywords
07

Timeline

A timeline is a sequence of steps the learner plays through in order. Each step can narrate, set state instantly, or animate to new values. Great for walkthroughs and guided reveals.

1 keywords
08

Loops & Logic

Prism has compile-time loops and conditionals that unroll before the scene is built. They use brace blocks, same as everything else. Generates static objects — the scene structure is always fixed at runtime.

6 keywords
09

Expressions & Math

Expressions appear in object properties (like the expr in curve f = <expr>), control bounds, and ${...} label interpolations. They're evaluated at runtime against the current state.

5 keywords

All keywords

lessonslide>goalonwrongexpectquiznumericbuildhotspotsketchmatchordersorttablesceneparamboolchoicecurveareapointlinelabelrectcirclepolygonvectorarcimagespace3point3segment3polygon3plane3label3slidertogglestepperpickerbuttonstepforifrepeatrevealletdefoperatorsmath functionsconstantsinterpolationf-strings
Part of the Mathly engine. Compiler lives at src/engine/lang/