tricu

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

runArboricxBundle.tri (787B)


      1 !import prelude *
      2 !import io *
      3 !import arboricx *
      4 !export *
      5 
      6 -- Read an Arboricx bundle from disk and execute it.
      7 -- This demo loads test/fixtures/id.arboricx and applies the
      8 -- default export to the string "hi".  The id bundle simply
      9 -- returns its argument, so the expected output is:
     10 --   hi
     11 --
     12 -- Run with --allow-read test/fixtures/id.arboricx or --unsafe-io.
     13 
     14 runBundle = (path arg :
     15   bind (readFile path)
     16     (result :
     17       matchResult
     18         (err rest : putStrLn "ERROR: Could not read bundle file")
     19         (bundleBytes rest :
     20           matchResult
     21             (err rest : putStrLn "ERROR: Could not execute bundle")
     22             (value rest : putStrLn value)
     23             (runArboricx bundleBytes arg))
     24         result))
     25 
     26 main = io (runBundle "test/fixtures/id.arboricx" "hi")