Interaction Trees in Zig and simple benchmarks
This commit is contained in:
26
demos/runArboricxBundle.tri
Normal file
26
demos/runArboricxBundle.tri
Normal file
@@ -0,0 +1,26 @@
|
||||
!import "../lib/base.tri" !Local
|
||||
!import "../lib/list.tri" !Local
|
||||
!import "../lib/io.tri" !Local
|
||||
!import "../lib/arboricx.tri" !Local
|
||||
|
||||
-- Read an Arboricx bundle from disk and execute it.
|
||||
-- This demo loads test/fixtures/id.arboricx and applies the
|
||||
-- default export to the string "hi". The id bundle simply
|
||||
-- returns its argument, so the expected output is:
|
||||
-- hi
|
||||
--
|
||||
-- Run with --allow-read test/fixtures/id.arboricx or --unsafe-io.
|
||||
|
||||
runBundle = (path arg :
|
||||
bind (readFile path)
|
||||
(result :
|
||||
matchResult
|
||||
(err rest : putStrLn "ERROR: Could not read bundle file")
|
||||
(bundleBytes rest :
|
||||
matchResult
|
||||
(err rest : putStrLn "ERROR: Could not execute bundle")
|
||||
(value rest : putStrLn value)
|
||||
(runArboricx bundleBytes arg))
|
||||
result))
|
||||
|
||||
main = io (runBundle "test/fixtures/id.arboricx" "hi")
|
||||
Reference in New Issue
Block a user