This new output form allows easy piping to the decode function of the tricu executable. Includes a new test for roundtrip evaluation of map, compilation to tree calculus terms, and decoding back to a human readable string.
		
			
				
	
	
		
			91 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			91 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
# tricu
 | 
						|
 | 
						|
## Introduction
 | 
						|
 | 
						|
tricu (pronounced like "tree-shoe" in English) is a purely functional interpreted language implemented in Haskell. [I'm](https://eversole.co) developing tricu to further research the possibilities offered by the various forms of [Tree Calculi](https://github.com/barry-jay-personal/typed_tree_calculus/blob/main/typed_program_analysis.pdf).
 | 
						|
 | 
						|
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
 | 
						|
1. Function definitions/assignments
 | 
						|
1. Lambda abstractions eliminated to Tree Calculus forms
 | 
						|
1. List, Number, and String literals
 | 
						|
1. Parentheses for grouping function application
 | 
						|
 | 
						|
These features move us cleanly out of the [turing tarpit](https://en.wikipedia.org/wiki/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?
 | 
						|
 | 
						|
```
 | 
						|
-- Anything after `--` on a single line is a comment
 | 
						|
-- We can define functions or "variables" as Tree Calculus values
 | 
						|
false = t 
 | 
						|
_ = t
 | 
						|
true = t t
 | 
						|
-- We can define functions as lambda expressions that are eliminated to Tree
 | 
						|
-- Calculus terms.
 | 
						|
id = (\a : a) -- `id` evaluates to the TC form of: t (t (t t)) t
 | 
						|
triage = (\a b c : t (t a b) c)
 | 
						|
-- Intensionality! We can inspect program structure, not just inputs/outputs:
 | 
						|
test = triage "Leaf" (\_ : "Stem") (\_ _ : "Fork")
 | 
						|
 | 
						|
-- REPL
 | 
						|
-- `tricu <` is the input prompt
 | 
						|
-- `tricu >` is the Tree Calculus form output. Most are elided below.
 | 
						|
-- `READ -:` is an attempt to interpret the TC output as strings/numbers.
 | 
						|
tricu < test t
 | 
						|
tricu > Fork (Fork Leaf (Fork ...) ... ) 
 | 
						|
READ -: "Leaf"
 | 
						|
tricu < test (t t)
 | 
						|
READ -: "Stem"
 | 
						|
tricu < test (t t t)
 | 
						|
READ -: "Fork"
 | 
						|
tricu < map (\i : listConcat i " is super cool!") [("Tree Calculus") ("Intensionality") ("tricu")]
 | 
						|
READ -: ["Tree Calculus is super cool!", "Intensionality is super cool!", "tricu is super cool!"]
 | 
						|
```
 | 
						|
 | 
						|
## Installation and Use
 | 
						|
 | 
						|
You can easily build and/or run this project using [Nix](https://nixos.org/download/).
 | 
						|
 | 
						|
- 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 - compiler 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 compile [OPTIONS]
 | 
						|
  Compile a file and return the result of the expression in the final line
 | 
						|
 | 
						|
  -f --file=FILE      Relative or absolute path to file input for compilation
 | 
						|
  -o --output=OUTPUT  Optional output file path for resulting output
 | 
						|
  -t --form=FORM      Output form: (tree|ast|ternary|ascii)
 | 
						|
 | 
						|
tricu decode [OPTIONS]
 | 
						|
  Decode a Tree Calculus value into a string representation
 | 
						|
 | 
						|
  -f --input=FILE     Optional file path containing a Tree Calculus value.
 | 
						|
                      Defaults to stdin.
 | 
						|
```
 | 
						|
 | 
						|
## Acknowledgements 
 | 
						|
 | 
						|
Tree Calculus was discovered by [Barry Jay](https://github.com/barry-jay-personal/blog). 
 | 
						|
 | 
						|
[treecalcul.us](https://treecalcul.us) is an excellent website with an intuitive playground created by [Johannes Bader](https://johannes-bader.com/) that introduced me to Tree Calculus. If tricu sounds interesting but compiling this repo sounds like a hassle, you should check out his site.
 |