2025-01-06 09:14:04 -06:00
2025-01-03 12:00:06 -06:00
2025-01-03 12:00:06 -06:00
2025-01-03 10:31:35 -06:00
2025-01-03 10:31:35 -06:00
2025-01-03 10:31:35 -06:00
2024-12-18 18:59:07 -06:00
2024-12-29 08:29:25 -06:00
2024-12-18 19:15:56 -06:00
2025-01-06 09:14:04 -06:00

tricu

Introduction

tricu (pronounced like "tree-shoe" in English) is a purely functional interpreted language implemented in Haskell. I'm developing tricu to further research the possibilities offered by the various forms of Tree Calculi.

tricu offers minimal syntax sugar yet manages to provide a complete, intuitive, and familiar programming environment. There is great power in simplicity. tricu offers:

  1. t operator behaving by the rules of Tree Calculus
  2. Function definitions/assignments
  3. Lambda abstractions eliminated to Tree Calculus forms
  4. List, Number, and String literals
  5. Parentheses for grouping function application

These features move us cleanly out of the turing tarpit territory that you may find yourself in if you try working only with the t operator.

tricu is the word for "tree" in Lojban: (x1) is a tree of species/cultivar (x2). This project was named "sapling" until I discovered the name is already being used for other (completely unrelated) programming language development projects.

What does it look like?

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 : lconcat i " world!") [("Hello, ")])
tricu > "Hello,  world!"
tricu < id (head (map (\i : lconcat i " world!") [("Hello, ")]))
tricu > "Hello,  world!"

tricu < -- Intensionality! We can inspect the structure of a function.
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 write a function to convert a function to source code
tricu < toTString id
tricu > "t (t (t t)) t"

Installation and Use

You can easily build and/or run this project using Nix.

  • Quick Start (REPL):
    • nix run git+https://git.eversole.co/James/tricu
  • Build executable in ./result/bin:
    • nix build git+https://git.eversole.co/James/tricu

./result/bin/tricu --help

tricu Evaluator and REPL

tricu [COMMAND] ... [OPTIONS]
  tricu: Exploring Tree Calculus

Common flags:
  -? --help       Display help message
  -V --version    Print version information

tricu [repl] [OPTIONS]
  Start interactive REPL

tricu eval [OPTIONS]
  Evaluate tricu and return the result of the final expression.

  -f --file=FILE  Input file path(s) for evaluation.
                    Defaults to stdin.
  -t --form=FORM  Optional output form: (tree|fsl|ast|ternary|ascii).
                    Defaults to tricu-compatible `t` tree form.

tricu decode [OPTIONS]
  Decode a Tree Calculus value into a string representation.

  -f --file=FILE  Optional input file path to attempt decoding.
                    Defaults to stdin.

Acknowledgements

Tree Calculus was discovered by Barry Jay.

treecalcul.us is an excellent website with an intuitive playground created by Johannes Bader that introduced me to Tree Calculus. If tricu sounds interesting but compiling this repo sounds like a hassle, you should check out his site.

Description
A micro-language for exploring Tree Calculus
Readme
Languages
Haskell 97%
Nix 3%