Introduces a read-only HTTP server (WAI/Warp) backed by the content store, exposing three bundle-export endpoints: - GET /bundle/name/:name — export by stored term name - GET /bundle/hash/:hash — export by full Merkle hash - GET /terms — plain-text listing (debug) Also adds `tricu server` (aka `--serve`) CLI mode, move `resolveExportTarget` / `namesForHash` / `looksLikeHash` out of `Main.hs` into `ContentStore.hs`, and cleans up unused exports and imports across `FileEval.hs` and `Wire.hs`.
92 lines
3.6 KiB
Markdown
92 lines
3.6 KiB
Markdown
# tricu
|
|
|
|
## Introduction
|
|
|
|
tricu (pronounced "tree-shoe") is a programming language experiment in Haskell. It is fundamentally based on the application of [Triage Calculus](https://olydis.medium.com/a-visual-introduction-to-tree-calculus-2f4a34ceffc2), an extended form 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.
|
|
|
|
tricu is the word for "tree" in Lojban: `(x1) is a tree of species/cultivar (x2)`.
|
|
|
|
I have fully embraced the slopmachine (LLM-assisted development) for this project. Nothing is stable or sacred. We will discover sanity at the end of the journey but we won't strive for it until then.
|
|
|
|
## Acknowledgements
|
|
|
|
Tree Calculus was discovered by [Barry Jay](https://github.com/barry-jay-personal/blog). The addition of Triage rules were suggested by [Johannes Bader](https://johannes-bader.com/). Johannes is also the creator of [treecalcul.us](https://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
|
|
|
|
tricu < !help
|
|
tricu version 1.1.0
|
|
Available commands:
|
|
!exit - Exit the REPL
|
|
!clear - Clear the screen
|
|
!reset - Reset preferences for selected versions
|
|
!help - Show tricu version and available commands
|
|
!output - Change output format (tree|fsl|ast|ternary|ascii|decode)
|
|
!definitions - List all defined terms in the content store
|
|
!import - Import definitions from file to the content store
|
|
!watch - Watch a file for changes, evaluate terms, and store them
|
|
!refresh - Refresh environment from content store (definitions are live)
|
|
!versions - Show all versions of a term by name
|
|
!select - Select a specific version of a term for subsequent lookups
|
|
!tag - Add or update a tag for a term by hash or name
|
|
```
|
|
|
|
## Installation and Use
|
|
|
|
You can easily build and 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 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|decode).
|
|
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.
|
|
```
|