2024-12-29 08:29:25 -06:00
# tricu
2024-12-18 19:15:56 -06:00
2024-12-27 15:40:50 -06:00
## Introduction
2025-01-26 08:52:28 -06:00
tricu (pronounced "tree-shoe") is a purely functional interpreted language implemented in Haskell. It is fundamentally based on the application of [Tree Calculus ](https://github.com/barry-jay-personal/typed_tree_calculus/blob/main/typed_program_analysis.pdf ) terms, but minimal syntax sugar is included to provide a useful programming tool. tricu is under active development and you can expect breaking changes with nearly every commit.
2024-12-29 08:29:25 -06:00
2025-01-24 16:14:33 -06:00
tricu is the word for "tree" in Lojban: `(x1) is a tree of species/cultivar (x2)` .
2024-12-18 19:15:56 -06:00
2025-01-24 16:14:33 -06:00
## Features
2024-12-29 10:37:37 -06:00
2025-01-24 16:14:33 -06:00
- Tree Calculus operator: `t`
- Assignments: `x = t t`
2025-01-27 16:04:04 -06:00
- Immutabile definitions
2025-01-24 16:14:33 -06:00
- Lambda abstraction syntax: `id = (\a : a)`
- List, Number, and String literals: `[(2) ("Hello")]`
- Function application: `not (not false)`
- Higher order/first-class functions: `map (\a : lconcat a "!") [("Hello")]`
- Intensionality blurs the distinction between functions and data (see REPL examples)
2025-01-27 16:04:04 -06:00
- Simple module system for code organization
2024-12-18 19:15:56 -06:00
2025-01-23 17:31:30 -06:00
## REPL examples
2024-12-27 15:40:50 -06:00
```
2025-01-02 19:08:14 -06:00
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!"
2025-01-24 16:14:33 -06:00
tricu < -- Intensionality ! We can inspect the structure of a function or data .
2025-01-02 19:08:14 -06:00
tricu < triage = ( \a b c : t ( t a b ) c )
tricu < test = triage " Leaf " ( \z : " Stem ") ( \a b : " Fork ")
2025-01-23 15:46:40 -06:00
tricu < test ( t t )
2025-01-02 19:08:14 -06:00
tricu > "Stem"
2025-01-23 17:31:30 -06:00
tricu < -- We can even convert a term back to source code ( / demos / toSource . tri )
2025-01-23 15:46:40 -06:00
tricu < toSource not ?
tricu > "(t (t (t t) (t t t)) (t t (t t t)))"
2025-01-23 18:57:59 -06:00
tricu < -- or calculate its size ( / demos / size . tri )
tricu < size not ?
tricu > 12
2024-12-27 15:40:50 -06:00
```
2024-12-31 10:00:52 -06:00
## Installation and Use
2024-12-27 15:40:50 -06:00
2025-01-24 16:14:33 -06:00
[Releases are available for Linux. ](https://git.eversole.co/James/tricu/releases )
Or you can easily build and/or run this project using [Nix ](https://nixos.org/download/ ).
2024-12-27 15:40:50 -06:00
2024-12-31 10:00:52 -06:00
- Quick Start (REPL):
2024-12-29 10:41:04 -06:00
- `nix run git+https://git.eversole.co/James/tricu`
2024-12-31 10:00:52 -06:00
- Build executable in `./result/bin` :
2024-12-29 10:41:04 -06:00
- `nix build git+https://git.eversole.co/James/tricu`
2024-12-31 10:09:36 -06:00
`./result/bin/tricu --help`
2024-12-31 10:00:52 -06:00
```
2025-01-01 08:17:05 -06:00
tricu Evaluator and REPL
2024-12-31 10:00:52 -06:00
tricu [COMMAND] ... [OPTIONS]
tricu: Exploring Tree Calculus
Common flags:
2025-01-01 19:32:41 -06:00
-? --help Display help message
-V --version Print version information
2024-12-31 10:00:52 -06:00
tricu [repl] [OPTIONS]
Start interactive REPL
2025-01-01 08:17:05 -06:00
tricu eval [OPTIONS]
2025-01-01 19:32:41 -06:00
Evaluate tricu and return the result of the final expression.
2024-12-31 10:00:52 -06:00
2025-01-01 19:32:41 -06:00
-f --file=FILE Input file path(s) for evaluation.
Defaults to stdin.
2025-01-26 15:33:12 -06:00
-t --form=FORM Optional output form: (tree|fsl|ast|ternary|ascii|decode).
2025-01-01 19:40:12 -06:00
Defaults to tricu-compatible `t` tree form.
2024-12-31 10:00:52 -06:00
tricu decode [OPTIONS]
2025-01-01 19:32:41 -06:00
Decode a Tree Calculus value into a string representation.
2024-12-31 10:00:52 -06:00
2025-01-01 19:32:41 -06:00
-f --file=FILE Optional input file path to attempt decoding.
Defaults to stdin.
2024-12-31 10:00:52 -06:00
```
2024-12-27 15:40:50 -06:00
2024-12-18 19:15:56 -06:00
## Acknowledgements
Tree Calculus was discovered by [Barry Jay ](https://github.com/barry-jay-personal/blog ).
2025-01-23 17:31:30 -06:00
[treecalcul.us ](https://treecalcul.us ) is an excellent website with an intuitive Tree Calculus code playground created by [Johannes Bader ](https://johannes-bader.com/ ) that introduced me to Tree Calculus.