tricu

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

stableBundleRuntime.tri (1254B)


      1 !import bundle_support *
      2 !export main
      3 !export emit
      4 
      5 -- Stable-backend runtime adapter, shared by every measured implementation.
      6 -- Fresh filesystem reads defeat repeated pure-result sharing. Input/expected
      7 -- trees are forced before checkpoint 1; results before checkpoint 2. Equality
      8 -- is checked afterward. No stageOn or argument-root force token is needed.
      9 -- forceTree is the same optimized, input-driven traversal for both variants;
     10 -- timing the stable backend's own traversal would obscure assembly costs.
     11 
     12 finish result expected = (matchBool
     13   (bind yield (_ : pure (ok (equal? result expected) t)))
     14   (abortIO "result forcing failed")
     15   (forceTree result))
     16 main function manifestPath nodesPath expectedPath = (io
     17   (onOk_ (readFile manifestPath) (manifest :
     18     onOk_ (readFile nodesPath) (nodes :
     19       onOk_ (readFile expectedPath) (expected : matchBool
     20         (bind yield (_ : finish (function manifest nodes) expected))
     21         (abortIO "input forcing failed")
     22         (and? (forceTree manifest) (and? (forceTree nodes) (forceTree expected))))))))
     23 emit function manifestPath nodesPath outputPath = (io
     24   (onOk_ (readFile manifestPath) (manifest :
     25     onOk_ (readFile nodesPath) (nodes : writeBytes outputPath (function manifest nodes)))))