Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Run a program

Save this as hello.plenty:

def main() -> Result[(), IoError | OverflowError[i64]]:
    print("Hello, Plenty!")?
    print(6 * 7)?
    Ok(())
Hello, Plenty!
42

In the directory where you saved the file, run:

plenty hello.plenty

A run compiles your file to a native executable and then runs it. If your shell cannot find plenty, follow Setting up first.

Plenty caches compiled code automatically. On supported Linux toolchains, unchanged runs also reuse the linked executable, so they do not link again. See the compile cache for invalidation and toolchain limits. The program still runs each time.

On Unix, you can put #!/usr/bin/env plenty before the first line, then run:

chmod +x hello.plenty
./hello.plenty

This uses the same automatic caches as plenty hello.plenty.

Execution begins at main. Indentation groups its statements; use four spaces. print prints one value followed by a newline. Put executable statements inside functions.

Printing can fail. The ? after each call continues when printing succeeds and returns an output error when it fails. Integer multiplication can overflow too, so the signature includes OverflowError[i64]. Its operands fit here, but the function still declares the arithmetic error contract. Ok(()) reports that the program finished successfully. Keep this pattern for printing; Absence and failure explains how to handle errors.

Each example is a complete program. Run it in a new file, along with any labelled companion modules shown on its page.