tricu

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

consumer_effect_files_pinned.tri (2313B)


      1 -- Authoring supplies both source units. Preparation constructs the package
      2 -- configuration; published exports execute it against runtime arguments.
      3 !import "prelude" !Local
      4 !import "io" !Local
      5 !import "consumers.structural" S
      6 !import "consumers.lexical-worker" L
      7 !import "consumers.unit-compile" U
      8 !import "consumers.effect-compose" E
      9 !import "consumers.effect-packages" Packages
     10 !import "consumers.file-effects" Files
     11 !import "consumers.copy-bytes" Copy
     12 
     13 source = __SCP_SOURCE__
     14 helperSource = __HELPER_SOURCE__
     15 conversionReceivers = ["convert" "convertEnd"]
     16 batchReceivers = ["writeAll" "writeNext"]
     17 configure rows helper = (bindResult (Packages.worker rows "removeCR") (transform _ :
     18   bindResult (Packages.worker rows "writeAll") (loop _ :
     19     bindResult (Packages.worker rows "reversePaths") (reverser _ :
     20       bindResult (Packages.preparedPackage rows "convert" conversionReceivers
     21         [(pair "copyText" helper)]) (conversion _ :
     22         bindResult (Packages.preparedPackage rows "writeAll" batchReceivers t) (batch _ :
     23           ok (pair helper (pair conversion (pair batch (pair transform (pair loop reverser))))) t))))))
     24 configuration = (bindResult (U.compileScpUnit source t) (rows _ :
     25   bindResult (Copy.compileSource helperSource) (packages _ : configure rows (snd packages))))
     26 helper config = fst config
     27 conversion config = fst (snd config)
     28 batch config = fst (snd (snd config))
     29 transform config = fst (snd (snd (snd config)))
     30 loop config = fst (snd (snd (snd (snd config))))
     31 reverser config = snd (snd (snd (snd (snd config))))
     32 runConvert sourcePath destination = (io (E.prepare configuration (config :
     33   (Packages.run Files.byteOperations (conversion config)
     34     (pair sourcePath destination) (transform config)))))
     35 runBatch paths = (io (E.prepare configuration (config :
     36   (Packages.run Files.byteOperations (batch config) paths
     37     (pair (loop config) (pair "batch\n" (pair (reverser config) t)))))))
     38 runError sourcePath destination = (io (E.prepare configuration (config :
     39   (Packages.run Files.byteOperations (helper config) sourcePath
     40     (pair (transform config) destination)))))
     41 runFault sourcePath destination = (io (E.prepare configuration (config :
     42   (Packages.run [(pair "ReadBytes" Files.readBytes)] (conversion config)
     43     (pair sourcePath destination) (transform config)))))
     44 t