Immutable definitions and documentation updates

This commit is contained in:
2025-01-24 16:14:33 -06:00
committed by James Eversole
parent 88b1c71695
commit 3175132eec
6 changed files with 137 additions and 32 deletions

View File

@ -2,13 +2,13 @@
-- even if it's a function. This includes lambdas which are eliminated to
-- Tree Calculus (TC) terms during evaluation.
-- Triage takes four arguments: the first three represent behaviors for each
-- `triage` takes four arguments: the first three represent behaviors for each
-- structural case in Tree Calculus (Leaf, Stem, and Fork).
-- The fourth argument is the value whose structure is inspected. By evaluating
-- the Tree Calculus term, `triage` enables branching logic based on the term's
-- shape, making it possible to perform structure-specific operations such as
-- reconstructing the terms' source code representation.
triage = (\a b c : t (t a b) c)
triage = (\leaf stem fork : t (t leaf stem) fork)
-- Base case of a single Leaf
sourceLeaf = t (head "t")
@ -34,13 +34,13 @@ sourceFork = (\convert : (\a b rest :
-- Wrapper around triage
toSource_ = y (\self arg :
triage
sourceLeaf -- Triage `a` case, Leaf
(sourceStem self) -- Triage `b` case, Stem
(sourceFork self) -- Triage `c` case, Fork
sourceLeaf -- `triage` "a" case, Leaf
(sourceStem self) -- `triage` "b" case, Stem
(sourceFork self) -- `triage` "c" case, Fork
arg) -- The term to be inspected
-- toSource takes a single TC term and returns a String
toSource = (\v : toSource_ v "")
exampleOne = toSource true -- OUT: "(t t)"
exampleTwo = toSource not? -- OUT: "(t (t (t t) (t t t)) (t t (t t t)))"
exampleTwo = toSource not? -- OUT: "(t (t (t t) (t t t)) (t t (t t t)))"