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