getting-started.md (6706B)
Write and run tricu in the Arboricx playground
tricu is the source language. Arboricx bundles carry its compiled, named tree values between runtimes. The playground at arbori.cx lets you edit modules and evaluate expressions using Haskell or Zig WebAssembly.
Basic Examples starts with Names and values, then introduces arithmetic, functions, lists, transformations and choices. Each lesson includes an expression, expected result and small edit exercise. For a compact syntax tour, select Language & Runtime Explorations → Language reference.
A complete first program
Choose Names and values in the Program selector. Replace its Source with:
!export answer
identity x = x
answer = identity 42
After a pause, the status becomes Compiled. In Expression enter answer,
choose Evaluated result, Natural number, and Pure value, then press
Evaluate. The result is 42. Source edits compile automatically; Evaluate
runs the expression. Stop discards ongoing work; edit again or use Compile
in Settings to prepare the current draft. Restore published source restores the
selected demo. You can also choose the module scratch example in Settings.
Definitions belong in Source. Expression uses the current definitions and
imports. !export answer selects the public bundle interface; private definitions
are also usable in the editor's expression scope. Every native module needs at
least one export. !export * exposes its local definitions.
Find and import libraries
Use Add import… below Source. Search by library purpose or exported name, select a library, inspect its exports/reference, choose a namespace, then insert. The picker checks the candidate with the native compiler and inserts one undoable edit. Existing imports have a jump action; ambiguous or unfinished source can use Copy import. Cancel closes the check. Installed local files appear alongside published libraries. Historical releases are available in the version selector.
For text-only assistance, use the library directory. Each release page includes its full manifest-hash import statement, complete exported names, available calling conventions, and source references. The machine-readable library index contains the same release identities and names. Choose a published version explicitly. Use its manifest as the import identity; its separate bundle SHA-256 identifies the downloadable file.
The playground resolves published and page-local manifests. The CLI additionally
resolves workspace source names such as !import prelude *; translate those names
to published manifest imports when adapting CLI examples for the playground.
Qualified imports make calls explicit: N.add 20 22. Imports belong in the module
header, before definitions. Imported names are available to expressions, while
reexports select the public interface. See modules.
Write source with the available syntax
- Application is curried:
f x ymeans(f x) y. Lambda:(x : x). - Names are ASCII identifiers; strings support Unicode scalar values.
- Numbers are natural numbers. Strings are lists of characters. Lists use spaces:
[1 2 3]; group applications as[(f 1) (f 2)]. - A pair value is
t left right;(left, right)is a pattern. - Patterns include
[],[head | tail],_, numeric/string literals and pins such as^B.true. Pattern equations need a final irrefutable fallback. - Functions can recurse directly; local self-recursion uses
let rec. let name = value in body,where,caseanddo operatorare supported.- Use library functions for arithmetic, comparisons and Boolean elimination. Function names and argument orders come from the selected library reference.
- Comments are
-- lineor|- block -|. Use spaces for layout. Group multiline applications in parentheses.
Read the language feature guide for practical conventions
and the language contract for exact syntax. In particular,
B.lazyBool thenThunk elseThunk condition takes branches before its condition;
B.matchResult onError onSuccess result passes both value/diagnostic and remainder
to a handler. Library protocols matter as much as function names.
Choose an output interpretation
| Value | Interpretation | Execution |
|---|---|---|
| Natural number | Natural number | Pure value |
| Character list | Text | Pure value |
| Boolean | Boolean | Pure value |
| General list, pair, function or other tree | tricu, △ source, DAG or Ternary | Pure value |
| Wrapped IO action | Interpretation of its final returned value | Text / line IO |
Text expects a character list. A list of strings should be joined using a library helper before displaying as Text. General lists can be inspected as trees. Stored definition displays the selected compiled value; Evaluated result runs Expression.
The tested examples include complete source, expression, output settings and expected results. Browser IO supports text output, line input, pure values, sequencing and abort. Libraries also describe host operations such as files and sockets; those require an appropriately configured native host.
Share programs and handle diagnostics
Export compiled module in Settings downloads the current public interface as
an .arboricx file. Settings → Local modules validates an imported file and makes
its manifest available to source imports. Local files stay in page memory through
Stop and backend changes, and are cleared on reload. Exported bundles include the
executable trees reachable from the public interface.
A compilation diagnostic belongs to the current source. Fix it before evaluating. Check spelling, exported names, manifest identities, argument order, required fallback patterns and indentation. A successful compilation still allows a computation to diverge; Stop remains available. The editor currently accepts 16,384 source scalars, 16 local definitions and up to 4,096 imported/public names. Large computations may exceed browser memory.
Guidance for text-only assistants
Start with this guide and the library directory. Fetch the release pages needed for the task, and consult source/protocol references for unfamiliar exports. Provide complete source, the expression to enter, output interpretation and execution mode. Derive expected results explicitly and distinguish a proposed program from one you have actually run. Published interfaces and these static references are readable through ordinary HTTP; playground execution is optional for looking up names, imports and conventions.