tricu

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

source-worker.tri (764B)


      1 !import prelude *
      2 !import io *
      3 !import consumers_base_source as B
      4 !import consumers_structural as S
      5 !import consumers_lexical_worker as L
      6 !export *
      7 -- Explicit single-source bootstrap for lessons and source-running examples.
      8 -- compileSource bytes initial returns a checked lexical worker; loadSource
      9 -- additionally reads a caller-selected path under the ordinary IO grant.
     10 -- No imports, dependency discovery, state defaults or CAS publication happen
     11 -- here. Use build-driver for native projects and source-free deployment.
     12 
     13 compileSource bytes initial = (bindResult (B.compileBaseSource bytes) (named _ :
     14   L.lCompile (S.makeConsumer initial (snd (snd named)))))
     15 loadSource path initial = (onOk_ (readFile path)
     16   (bytes : pure (compileSource bytes initial)))