tricu/README.md

57 lines
2.1 KiB
Markdown
Raw Normal View History

2024-12-18 19:15:56 -06:00
# sapling
## Introduction
2024-12-28 22:20:43 -06:00
sapling is a "micro-language" that [I'm](https://eversole.co) working on to investigate [Tree Calculus](https://github.com/barry-jay-personal/typed_tree_calculus/blob/main/typed_program_analysis.pdf) .
2024-12-18 19:15:56 -06:00
2024-12-28 22:20:43 -06:00
It offers a minimal amount of syntax sugar yet provides a complete and intuitive programming environment. Sapling offers:
2024-12-18 19:15:56 -06:00
- `t` operator behaving by the rules of Tree Calculus
- Function ("variable") definitions
2024-12-18 19:15:56 -06:00
- Lambda abstractions
2024-12-28 22:20:43 -06:00
- List, Number, and String literals
2024-12-18 19:15:56 -06:00
## What does it look like?
```
2024-12-28 22:20:43 -06:00
-- Anything after `--` on a 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) -- t (t (t t)) t
triage = (\a b c : t (t a b) c)
triage = (\a b c : t (t a b) c)
-- Intensionality !!!
test = triage "Leaf" (\_ : "Stem") (\_ _ : "Fork")
-- REPL
-- `sapling <` is the input prompt
-- `sapling >` is the Tree Calculus form output. Most are elided below.
-- `DECODE -:` is an attempt to interpret the TC output as strings/numbers.
sapling < test t
2024-12-28 22:20:43 -06:00
sapling > Fork (Fork Leaf (Fork ...) ... )
DECODE -: "Leaf"
sapling < test (t t)
2024-12-28 22:20:43 -06:00
DECODE -: "Stem"
sapling < test (t t t)
2024-12-28 22:20:43 -06:00
DECODE -: "Fork"
sapling < map (\i : listConcat i " is super cool!") [("He") ("She") ("Everybody")]
DECODE -: ["He is super cool!", "She is super cool!", "Everybody is super cool!"]
```
2024-12-28 21:58:52 -06:00
## Installation
2024-12-28 21:58:52 -06:00
You can easily build and/or run this project using [Nix](https://nixos.org/download/).
2024-12-28 21:58:52 -06:00
- Build REPL binary: `nix build git+https://git.eversole.co/James/sapling`
- Run REPL: `nix run git+https://git.eversole.co/James/sapling`
2024-12-18 19:15:56 -06:00
## Acknowledgements
Tree Calculus was discovered by [Barry Jay](https://github.com/barry-jay-personal/blog).
2024-12-18 19:41:12 -06:00
[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 sapling sounds interesting but compiling this repo sounds like a hassle, you should check out his site.