From ca238f9c89d3156842b0a3d5fe24a5d69b2eedb0 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 6 Apr 2018 08:32:41 -0400 Subject: - Adapted new-luxc's code to latest stdlib changes. --- new-luxc/source/luxc/cache/description.lux | 13 +++++++------ new-luxc/source/luxc/cache/io.lux | 31 +++++++++++++++++------------- 2 files changed, 25 insertions(+), 19 deletions(-) (limited to 'new-luxc/source/luxc/cache') diff --git a/new-luxc/source/luxc/cache/description.lux b/new-luxc/source/luxc/cache/description.lux index 1bfb1209c..cce2e783d 100644 --- a/new-luxc/source/luxc/cache/description.lux +++ b/new-luxc/source/luxc/cache/description.lux @@ -12,7 +12,8 @@ ["s" syntax #+ Syntax])) [///lang]) -(exception: #export Invalid-Lux-Version) +(exception: #export (Invalid-Lux-Version {message Text}) + message) (def: (write-type type) (-> Type Code) @@ -56,20 +57,20 @@ (def: read-type (Syntax Type) (let [tagged (: (All [a] (-> Text (Syntax a) (Syntax a))) - (function [tag syntax] + (function (_ tag syntax) (s.form (p.after (s.this (code.text tag)) syntax)))) binary (: (-> Text (Syntax Type) (Syntax [Type Type])) - (function [tag read-type] + (function (_ tag read-type) (tagged tag (p.seq read-type read-type)))) indexed (: (-> Text (Syntax Nat)) - (function [tag] + (function (_ tag) (tagged tag s.nat))) quantified (: (-> Text (Syntax Type) (Syntax [(List Type) Type])) - (function [tag read-type] + (function (_ tag read-type) (tagged tag (p.seq (s.tuple (p.some read-type)) read-type))))] (p.rec - (function [read-type] + (function (_ read-type) ($_ p.alt (tagged "Primitive" (p.seq s.text (p.some read-type))) (s.this (` "Void")) diff --git a/new-luxc/source/luxc/cache/io.lux b/new-luxc/source/luxc/cache/io.lux index 9f5474c76..8c4367989 100644 --- a/new-luxc/source/luxc/cache/io.lux +++ b/new-luxc/source/luxc/cache/io.lux @@ -21,11 +21,16 @@ [//influences] [//]) -(exception: #export Invalid-Lux-Version) -(exception: #export Module-Is-Not-Cached) -(exception: #export Cannot-Pre-Load-Cache-More-Than-Once) -(exception: #export Cannot-Delete-Cached-File) -(exception: #export Cannot-Load-Definition) +(do-template [] + [(exception: #export ( {message Text}) + message)] + + [Invalid-Lux-Version] + [Module-Is-Not-Cached] + [Cannot-Pre-Load-Cache-More-Than-Once] + [Cannot-Delete-Cached-File] + [Cannot-Load-Definition] + ) (def: cache (Atom //.Cache) @@ -47,7 +52,7 @@ (do io.Monad [roots (file.files target-dir) root-modules (monad.map @ (: (-> File (Process (List File))) - (function recur [file] + (function (recur file) (do @ [is-dir? (file.directory? file)] (if is-dir? @@ -74,7 +79,7 @@ [#let [module-dir (///io.file target-dir module-name)] files (file.files module-dir) can-delete-module-dir? (<| (:: @ map (list.every? (bool/= true))) - (monad.map @ (function [file] + (monad.map @ (function (_ file) (do @ [? (file.directory? file)] (if ? @@ -129,7 +134,7 @@ (-> File Loader Text Module (Process Module)) (do io.Monad [definitions (monad.map @ (: (-> [Text Definition] (Process [Text Definition])) - (function [[def-name [def-type def-annotations _]]] + (function (_ [def-name [def-type def-annotations _]]) (do @ [def-blob (file.read (///io.file target-dir (format module-name "/" def-name))) #let [def-ident [module-name def-name]]] @@ -156,21 +161,21 @@ (dict.from-list text.Hash)))) #let [_ (log! "pre-load' #2")] #let [candidate-entries (dict.entries candidate-cache) - raw-influences (list/fold (function [[candidate-name candidate-module] influences] + raw-influences (list/fold (function (_ [candidate-name candidate-module] influences) (list/fold (//influences.track candidate-name) influences (get@ #.imports candidate-module))) //influences.empty candidate-entries) - pruned-influences (list/fold (function [[candidate-name candidate-module] influences] - (if (list.every? (function [module-name] + pruned-influences (list/fold (function (_ [candidate-name candidate-module] influences) + (if (list.every? (function (_ module-name) (dict.contains? module-name candidate-cache)) (get@ #.imports candidate-module)) influences (//influences.untrack candidate-name influences))) raw-influences candidate-entries) - valid-cache (list/fold (function [candidate cache] + valid-cache (list/fold (function (_ candidate cache) (if (dict.contains? candidate pruned-influences) cache (dict.remove candidate cache))) @@ -178,7 +183,7 @@ (dict.keys candidate-cache))] #let [_ (log! "pre-load' #3")]] (|> (dict.entries valid-cache) - (monad.map @ (function [[module-name module]] + (monad.map @ (function (_ [module-name module]) (do @ [#let [_ (log! (format " PRE INSTALL: " module-name))] loaded-module (install target-dir load-def module-name module) -- cgit v1.2.3