tricu

A lazy functional language based on Tree Calculus
Log | Files | Refs | README | LICENSE

2bd3e520f8a282604fe7683a9ecef2636d3d4151961cd0cd9a7348e64cef18d1.tri (1044B)


      1 !import base as B
      2 !import io as IO
      3 !import io_storage as Storage
      4 !import io_text as Text
      5 !import arboricx as Bundle
      6 !export main
      7 !export run
      8 !export runBundle
      9 -- Whole-bundle source decoding is explicitly bounded, not a streaming decoder.
     10 -- Selecting/executing this program is authority to execute the selected bundle;
     11 -- bundle validation alone is not authentication or a computation-resource quota.
     12 -- Container remainders are internal directory cursors, not unconsumed input;
     13 -- bytes outside declared sections are permitted by the portable reader profile.
     14 runBundle path argument = IO.bind (Storage.readBytes path 1048576) (read : case read of
     15   ((t t), (bytes, t)) = case Bundle.runArboricx bytes argument of
     16     ((t t), (value, _)) = IO.require IO.stdout (writer : IO.require (Text.writeText writer (B.append value "\n")) IO.pure)
     17     _ = IO.fail "Could not validate/execute bundle"
     18   _ = IO.fail "Could not read bundle file")
     19 main = IO.io (runBundle "test/fixtures/id.arboricx" "hi")
     20 run path argument = IO.io (runBundle path argument)