tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

source.tri (935B)


      1 !import prelude *
      2 !import io *
      3 !import consumers_source_worker as Source
      4 !import consumers_lexical_worker as L
      5 !export *
      6 -- Run from repository root with --io --allow-read demos/consumers/lessons
      7 -- --allow-read lib/consumer. The source renderer is written in SCP.
      8 
      9 load path initial = Source.loadSource path initial
     10 lesson name = append "demos/consumers/lessons/source/" (append name ".scp")
     11 showTree printer label tree = putStrLn (append label
     12   (resultOr "ERROR" (L.lRunChecked printer tree)))
     13 run = do onOk_
     14   appender <- load "lib/consumer/append.scp" t
     15   joiner <- load (lesson "join") appender
     16   printer <- load (lesson "to-source") joiner
     17   thenIO (showTree printer "Leaf: " t)
     18     (thenIO (showTree printer "Stem Leaf: " (t t))
     19       (thenIO (showTree printer "Fork Leaf Leaf: " (t t t))
     20         (thenIO (showTree printer "Identity function: " (x : x))
     21           (showTree printer "String a as a tree: " "a"))))
     22 main = io run