Patch handbook · Examples

Start from a program that already works.

The repository examples are exercised by Patch's test suite. Use the small programs to learn one idea at a time, Workshop Desk for the Current Ready native path, and Patch Studio Showcase for the complete current Studio/Web authoring surface.

window "Hello" size 360, 180:
  text "Hello, Patch!" at 24, 24 size 220, 32

Starter examples

Beginner · Console

Hello World

The smallest useful Patch program: create text and show it.

hello-world.patch
Beginner · Window

Hello Window

A tiny Window application for learning Form and Text syntax.

hello-window.patch
Beginner · Window

Counter

Persistent number state, interpolation, a Button event and explicit change.

counter-window.patch
Beginner · Language

Conditions

A compact if/else example without GUI noise.

conditions.patch

GUI component examples

Use these when you want a working source pattern for common controls and event semantics.

ExampleWhat it teachesSource
Checkbox WindowBoolean state, Checkbox changed event and explicit persistence.checkbox-window.patch
Combo WindowComboBox options and transient text selection.combo-window.patch
TimePicker WindowStudio/Web source-backed # @input-mode time with local HH:MM text and explicit native fail-closed behavior.timepicker-window.patch
Calendar WindowStudio/Web inline month grid via # @input-mode calendar, transient month navigation and explicit ISO-date persistence.calendar-window.patch
Counter WindowButton click, bound Text and source-backed geometry.counter-window.patch
Chrome WindowWindow chrome controls such as Panel, Timer, StatusBar and Picture on the supported product path.chrome-window.patch
Workshop DeskSeven Forms, a revision-aware quote workflow, Current Ready native controls, source-backed events, Designer stress and Native GUI IR 1.9 / runtime v1.10 acceptance.workshop-desk.patch
Patch Studio ShowcaseA running review desk on Project v4: Things, recipes, ranged calls, repeat and if, plus Registry 0.10 and the Studio/Web surface, including Memo, PasswordEdit, MaskedEdit, NumberEdit, DatePicker, TimePicker, Calendar, CheckedListBox and passive ProgressBar.patch-studio-showcase.patchproject

GUI selection remains transient unless your handler performs an explicit Patch change. ProgressBar is intentionally passive and has no control event. The exact supported component/target combination is checked fail-closed by current build readiness.

Language and compiler examples

Intermediate

Direct Wasm basics

A small program inside the direct WebAssembly numeric subset.

direct-wasm.patch

Formal-assurance examples

These are for users who want to inspect the mechanized assurance pipeline. The formal claim remains deliberately narrower than the full Patch language and current RAD product.

ExampleFocusSource
Formal callsAcyclic ranked recipe environments and bounded call arguments.formal-calls.patch
Arithmetic callsArithmetic argument binding inside the mechanized range fragment.formal-calls-arithmetic.patch
Callee traceStructured source-visible callee effect trace.formal-callee-trace.patch
Guarded calleeParameter guard selection and exact branch witness.formal-callee-guard.patch
Transitive repeated callsFrame identity when identical call sites execute repeatedly.formal-transitive-calls-repeated.patch
Mixed guardsRepeated call frames with different guard paths.formal-transitive-calls-mixed-guards.patch

Showcases: Studio/Web and Current Ready native

Patch Studio Showcase

The canonical multi-file Project-v4 acceptance project is a running review desk. Save profile stores the account on a Thing, scores the review with a ranged recipe, and branches on the active flag. It also covers every Registry 0.10 component, source-backed R4 presets and advanced Table columns. Its Component Gallery demonstrates source-backed per-column width/alignment alongside PasswordEdit, MaskedEdit, NumberEdit, DatePicker, TimePicker, CheckedListBox and a passive ProgressBar using # @slider-mode progress. It is selectable directly in hosted and Offline Studio.

Workshop Desk

Workshop Desk is the running Current Ready acceptance application. Its seven Forms take a ticket from quote to ready, then open settings, job details, inventory, a customer profile, diagnostics and a native component gallery. Studio/Web-only presets stay out of Native GUI IR 1.9.

Why there are two

Repository tests compile and exercise both boundaries deliberately. The Showcase can demonstrate Studio/Web-only controls while native builds fail closed; Workshop Desk continuously proves the Current Ready Native GUI IR 1.9 / payload v19 / runtime v1.10 path.

Suggested learning order

  1. Hello World
  2. Counter Window
  3. Checkbox Window and Combo Window
  4. Change capabilities
  5. Workshop Desk for the native Ready path
  6. Patch Studio Showcase for the complete current Studio/Web surface
  7. Only then move into the formal examples if you need the assurance pipeline.

Follow the step-by-step tutorials