tricu

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

command.tri (2300B)


      1 !import prelude *
      2 !import io *
      3 !import consumers_build_driver as D
      4 !import consumers_file as File
      5 !import source_module as M
      6 !export *
      7 -- Shared CLI phase actions. Request construction/execution/publication remain
      8 -- tricu-owned; the outer process supplies selection, data and deadlines.
      9 
     10 problem phase value = (do bind
     11   _ <- putStrLn (append phase "-error")
     12   _ <- putStrLn (append "failure-detail=" (File.detail value))
     13   pure value)
     14 build root request = (io (onResult_ (D.buildCode root request)
     15   (value : problem "code-build" value)
     16   (result : do bind
     17     _ <- putStrLn (append "code-manifest=" (D.codeManifest result))
     18     _ <- putStrLn (append "code-receipt=" (D.codeReceipt result))
     19     putStrLn "code-build-ok")))
     20 configure root manifest entry inputAction stateAction = (configurationOutput
     21   (onOk_ inputAction (input : onOk_ stateAction (state :
     22     D.configurePinned root (D.configurationRequest manifest entry input state)))))
     23 bindEntry root manifest entry name stateAction = (configurationOutput
     24   (onOk_ stateAction (state :
     25     D.bindPinned root (D.entryConfigurationRequest manifest entry name state))))
     26 configurationOutput action = (io (onResult_ action
     27   (value : problem "configuration" value)
     28   (result : do bind
     29     _ <- putStrLn (append "workers=" (D.configurationWorkers result))
     30     _ <- putStrLn (append "invocations=" (D.configurationInvocations result))
     31     _ <- putStrLn (append "configuration-receipt=" (D.configurationReceipt result))
     32     putStrLn "configuration-ok")))
     33 -- Selection verifies the explicit export without executing its invocation.
     34 -- A direct tree program needs no file adapter or additional publication.
     35 selectInvocation root manifest entry = (io (onResult_
     36   (M.sourceModuleLoadSelected root manifest entry)
     37   (value : problem "invocation-selection" value)
     38   (_ : do bind
     39     _ <- putStrLn (append "invocations=" manifest)
     40     putStrLn "invocation-ready")))
     41 publishFile root manifest entry label = (io (onResult_
     42   (onOk_ (M.sourceModuleLoadSelected root manifest entry)
     43     (invoke : M.sourceModulePublishNames root
     44       [(pair "processFile" (path : File.program label invoke path))] ["processFile"]))
     45   (value : problem "file-build" value)
     46   (manifest : do bind
     47     _ <- putStrLn (append "file-manifest=" manifest)
     48     putStrLn "file-build-ok")))