tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

README.md (3009B)


tricu

Introduction

tricu (pronounced "tree-shoe") is an experimental programming language written in Haskell. It is fundamentally based on the application of Triage Calculus, an extended form of Tree Calculus.

tricu is the word for "tree" in Lojban: (x1) is a tree of species/cultivar (x2).

In the ext/ directory there are implementations of Tree Calculus evaluators languages besides Haskell. Here be dragons; beware.

Acknowledgements

Tree Calculus was discovered by Barry Jay. The addition of Triage rules were suggested by Johannes Bader. Johannes is also the creator of treecalcul.us which has a great intuitive code playground using his language LambAda.

REPL examples

tricu < -- Anything after `--` on a single line is a comment
tricu < id = (a : a) -- Lambda abstraction is eliminated to tree calculus terms
tricu < head (map (i : append i " world!") [("Hello, ")])
tricu > "Hello,  world!"
tricu < id (head (map (i : append i " world!") [("Hello, ")]))
tricu > "Hello,  world!"

tricu < -- Intensionality! We can inspect the structure of a function or data.
tricu < triage = (a b c : t (t a b) c)
tricu < test = triage "Leaf" (z : "Stem") (a b : "Fork")
tricu < test (t t)
tricu > "Stem"

tricu < -- We can even convert a term back to source code (/demos/toSource.tri)
tricu < toSource not?
tricu > "(t (t (t t) (t t t)) (t t (t t t)))"
tricu < -- or calculate its size (/demos/size.tri)
tricu < size not?
tricu > 12

Installation and Use

You can easily build and run this project using Nix.

./result/bin/tricu --help

Usage

CLI

Evaluate one or more files:

tricu eval program.tri
tricu eval --format decode program.tri
tricu eval --output result.txt program.tri

Compile/import/export Arboricx bundles:

tricu arboricx compile --file program.tri --output program.arboricx
tricu arboricx import --file program.arboricx --module program
tricu arboricx export --module prelude --output prelude.arboricx

REPL

Running tricu with no subcommand starts the REPL. The REPL uses the same filesystem content store and workspace module loader as the CLI.

Useful commands:

!load FILE          load/evaluate a .tri file without printing a result
!store [PATH]       show or set the content-addressed store
!format decode      set output format by name
!env                list current in-memory bindings

!load supports filename tab completion. Normal REPL input also supports tab completion for names currently in the REPL environment.