configurations.scp (2373B)
1 -- Native module: two independently selected pipelines and a counter. 2 !import base as Base 3 !import application as App 4 !export configureData 5 !export configureNonempty 6 !export configureCounter 7 8 -- This constructor centralizes the existing worker ABI. Its input code 9 -- comes from checked local compilation or explicitly trusted imported trees. 10 consumer makeWorker 11 (initial, code) @ _ => ("scp-worker.v1", (initial, code)) 12 13 -- Bootstrap one constructor worker by ordinary tree construction. The 14 -- build invocation supplies no magic default, compiler callback, or resolver. 15 consumer constructor 16 _ @ _ => ("scp-worker.v1", (leaf, Self.makeWorker)) 17 18 -- Input: explicit constructor worker. These configurations ignore state. 19 consumer counter 20 make @ _ => 21 call make (leaf, Base.succBinary) as successor in 22 call make ((0, (leaf, successor)), Base.countLines) as worker in worker 23 24 consumer splitter 25 make @ _ => 26 call make (leaf, Base.prepend) as prepender in 27 call make (leaf, Base.fold) as folder in 28 call make ((folder, prepender), Base.reverse) as reverser in 29 call make (([], reverser), Base.splitLines) as worker in worker 30 31 -- Input selects a predicate entry, while both configurations share the 32 -- same splitter/filter/application code and the same construction algorithm. 33 consumer pipeline 34 (make, predicateCode) @ _ => 35 call make (leaf, Self.splitter) as buildSplit in 36 call buildSplit make as split in 37 call make (leaf, predicateCode) as predicate in 38 call make (predicate, Base.filter) as filtering in 39 call make ((split, filtering), App.dataLines) as worker in worker 40 41 consumer configureData 42 _ @ _ => 43 call ("scp-worker.v1", (leaf, Self.constructor)) leaf as make in 44 call make (leaf, Self.pipeline) as buildPipeline in 45 call buildPipeline (make, App.dataLine) as worker in 46 [("dataLines", worker) | []] 47 48 consumer configureNonempty 49 _ @ _ => 50 call ("scp-worker.v1", (leaf, Self.constructor)) leaf as make in 51 call make (leaf, Self.pipeline) as buildPipeline in 52 call buildPipeline (make, Base.nonempty) as worker in 53 [("nonemptyLines", worker) | []] 54 55 consumer configureCounter 56 _ @ _ => 57 call ("scp-worker.v1", (leaf, Self.constructor)) leaf as make in 58 call make (leaf, Self.counter) as buildCounter in 59 call buildCounter make as worker in [("countLines", worker) | []]