diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/tool/compiler/meta/cache.lux | 16 | ||||
-rw-r--r-- | stdlib/source/lux/tool/compiler/meta/cache/dependency.lux | 33 | ||||
-rw-r--r-- | stdlib/source/lux/tool/compiler/meta/io.lux | 2 | ||||
-rw-r--r-- | stdlib/source/lux/tool/compiler/meta/io/archive.lux | 46 |
4 files changed, 56 insertions, 41 deletions
diff --git a/stdlib/source/lux/tool/compiler/meta/cache.lux b/stdlib/source/lux/tool/compiler/meta/cache.lux index bb4c4d8c8..fbf7fe128 100644 --- a/stdlib/source/lux/tool/compiler/meta/cache.lux +++ b/stdlib/source/lux/tool/compiler/meta/cache.lux @@ -6,7 +6,7 @@ ["ex" exception (#+ exception:)] pipe] [data - ["." bit ("#;." equivalence)] + ["." bit ("#@." equivalence)] ["." maybe] ["." product] [number @@ -16,7 +16,7 @@ ["." text [format (#- Format)]] [collection - ["." list ("#;." functor fold)] + ["." list ("#@." functor fold)] ["dict" dictionary (#+ Dictionary)] ["." set (#+ Set)]]] [world @@ -94,7 +94,7 @@ (do @ [_ (..delete System<m> file)] (wrap #1))))))] - [(list.every? (bit;= #1)) + [(list.every? (bit@= #1)) (if> [(..delete System<m> document)] [(wrap [])])])))) @@ -152,7 +152,7 @@ (do> @ [(..cached System<m>)] [(monad.map @ (load-document System<m> contexts root key binary)) - (:: @ map (list;fold (function (_ full-document archive) + (:: @ map (list@fold (function (_ full-document archive) (case full-document (#.Some [[module references] document]) (dict.put module [references document] archive) @@ -162,17 +162,17 @@ (: (Dictionary Text [(List Module) (Ex [d] (Document d))]) (dict.new text.hash))))])) #let [candidate-entries (dict.entries candidate) - candidate-dependencies (list;map (product.both id product.left) + candidate-dependencies (list@map (product.both id product.left) candidate-entries) candidate-archive (|> candidate-entries - (list;map (product.both id product.right)) + (list@map (product.both id product.right)) (dict.from-list text.hash)) graph (|> candidate dict.entries - (list;map (product.both id product.left)) + (list@map (product.both id product.left)) /dependency.graph (/dependency.prune candidate-archive)) - archive (list;fold (function (_ module archive) + archive (list@fold (function (_ module archive) (if (dict.contains? module graph) archive (dict.remove module archive))) diff --git a/stdlib/source/lux/tool/compiler/meta/cache/dependency.lux b/stdlib/source/lux/tool/compiler/meta/cache/dependency.lux index ec01baf45..bb3736518 100644 --- a/stdlib/source/lux/tool/compiler/meta/cache/dependency.lux +++ b/stdlib/source/lux/tool/compiler/meta/cache/dependency.lux @@ -3,29 +3,32 @@ [data ["." text] [collection - ["." list ("#;." functor fold)] - ["dict" dictionary (#+ Dictionary)]]]] + ["." list ("#@." functor fold)] + ["." dictionary (#+ Dictionary)]]]] [///io (#+ Module)] [///archive (#+ Archive)]) -(type: #export Graph (Dictionary Module (List Module))) +(type: #export Graph + (Dictionary Module (List Module))) -(def: #export empty Graph (dict.new text.hash)) +(def: #export empty + Graph + (dictionary.new text.hash)) (def: #export (add to from) (-> Module Module Graph Graph) - (|>> (dict.update~ from (list) (|>> (#.Cons to))) - (dict.update~ to (list) id))) + (|>> (dictionary.update~ from (list) (|>> (#.Cons to))) + (dictionary.update~ to (list) id))) (def: dependents - (-> Module Graph (Maybe (List Text))) - dict.get) + (-> Module Graph (Maybe (List Module))) + dictionary.get) (def: #export (remove module dependency) (-> Module Graph Graph) (case (dependents module dependency) (#.Some dependents) - (list;fold remove (dict.remove module dependency) dependents) + (list@fold remove (dictionary.remove module dependency) dependents) #.None dependency)) @@ -36,18 +39,18 @@ (def: #export (dependency [module imports]) (-> Dependency Graph) - (list;fold (..add module) ..empty imports)) + (list@fold (..add module) ..empty imports)) (def: #export graph (-> (List Dependency) Graph) - (|>> (list;map ..dependency) - (list;fold dict.merge empty))) + (|>> (list@map ..dependency) + (list@fold dictionary.merge empty))) (def: #export (prune archive graph) (-> Archive Graph Graph) - (list;fold (function (_ module graph) - (if (dict.contains? module archive) + (list@fold (function (_ module graph) + (if (dictionary.contains? module archive) graph (..remove module graph))) graph - (dict.keys graph))) + (dictionary.keys graph))) diff --git a/stdlib/source/lux/tool/compiler/meta/io.lux b/stdlib/source/lux/tool/compiler/meta/io.lux index 579164881..271dcb79a 100644 --- a/stdlib/source/lux/tool/compiler/meta/io.lux +++ b/stdlib/source/lux/tool/compiler/meta/io.lux @@ -14,3 +14,5 @@ (def: #export (sanitize system) (All [m] (-> (System m) Text Text)) (text.replace-all "/" (:: system separator))) + +(def: #export lux-context "lux") diff --git a/stdlib/source/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/lux/tool/compiler/meta/io/archive.lux index abb8b75c6..2a5713f4f 100644 --- a/stdlib/source/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/lux/tool/compiler/meta/io/archive.lux @@ -16,56 +16,66 @@ ["%" format (#+ format)]]] [world ["." file (#+ Path File System)]]] - ["." // (#+ Module)]) + ["." // (#+ Module) + [// + ["." archive]]]) (exception: #export (cannot-prepare {archive Path} - {module Module} + {module-id archive.ID} {error Text}) (exception.report ["Archive" archive] - ["Module" module] + ["Module ID" (%.nat module-id)] ["Error" error])) (def: #export (archive system host root) (-> (System Promise) Host Path Path) (format root (:: system separator) host)) -(def: #export (document system host root module) - (-> (System Promise) Host Path Module Path) +(def: #export (lux-archive system host root) + (-> (System Promise) Host Path Path) (format (..archive system host root) (:: system separator) - (//.sanitize system module))) + //.lux-context)) + +(def: #export (document system host root module-id) + (-> (System Promise) Host Path archive.ID Path) + (format (..lux-archive system host root) + (:: system separator) + (%.nat module-id))) -(def: #export (artifact system host root module name) - (-> (System Promise) Host Path Module Text Path) - (format (document system host root module) +(def: #export (artifact system host root module-id name extension) + (-> (System Promise) Host Path archive.ID Text Text Path) + (format (document system host root module-id) (:: system separator) - (//.sanitize system name))) + name + extension)) -(def: #export (prepare system host root module) - (-> (System Promise) Host Path Module (Promise (Try Any))) +(def: #export (prepare system host root module-id) + (-> (System Promise) Host Path archive.ID (Promise (Try Any))) (do promise.monad - [#let [document (..document system host root module)] + [#let [document (..document system host root module-id)] document-exists? (file.exists? promise.monad system document)] (if document-exists? (wrap (#try.Success [])) (do @ - [outcome (!.use (:: system create-directory) document)] + [_ (file.get-directory @ system (..lux-archive system host root)) + outcome (!.use (:: system create-directory) document)] (case outcome (#try.Success output) (wrap (#try.Success [])) (#try.Failure error) (wrap (exception.throw ..cannot-prepare [(..archive system host root) - module + module-id error]))))))) -(def: #export (write system host root module name content) - (-> (System Promise) Host Path Module Text Binary (Promise (Try Any))) +(def: #export (write system host root module-id name extension content) + (-> (System Promise) Host Path archive.ID Text Text Binary (Promise (Try Any))) (do (try.with promise.monad) [artifact (: (Promise (Try (File Promise))) (file.get-file promise.monad system - (..artifact system host root module name)))] + (..artifact system host root module-id name extension)))] (!.use (:: artifact over-write) content))) (def: #export (module system host root document) |