diff options
author | Eduardo Julian | 2019-02-03 01:38:44 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-02-03 01:38:44 -0400 |
commit | 2607c95980e87f5f270e1fe6eaf7a7b3311ca138 (patch) | |
tree | 1ed1db89a9e7fd24f7d300b56aa19e4f9c4c4f39 /stdlib/source/lux.lux | |
parent | fb9202536a4c668f477da2d85af484800e2a3f0c (diff) |
Improved syntax for domains/parallel-import-trees.
Diffstat (limited to 'stdlib/source/lux.lux')
-rw-r--r-- | stdlib/source/lux.lux | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index c22036ef2..d3a0f1825 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -4246,23 +4246,17 @@ " Relative Root: " relative-root ..new-line)))))) (def: (alter-domain alteration domain import) - (-> Int Text Importation Importation) + (-> Nat Text Importation Importation) (let [[import-name import-alias import-refer] import original (text/split-all-with ..module-separator import-name) - [pre post] (if (i/< +0 alteration) - [(list) (list/drop (.nat (i/* -1 alteration)) original)] - [(list/take (.nat alteration) original) - (list/drop (.nat alteration) original)]) - altered ($_ list/compose - pre - (case domain - "" - (list) + truncated (list/drop (.nat alteration) original) + parallel (case domain + "" + truncated - _ - (list domain)) - post)] - {#import-name (text/join-with ..module-separator altered) + _ + (list& domain truncated))] + {#import-name (text/join-with ..module-separator parallel) #import-alias import-alias #import-refer import-refer})) @@ -4273,6 +4267,7 @@ (: (-> Code (Meta (List Importation))) (function (_ token) (case token + ## Simple [_ (#Identifier ["" m-name])] (do Monad<Meta> [m-name (clean-module nested? relative-root m-name)] @@ -4281,6 +4276,7 @@ #import-refer {#refer-defs #All #refer-open (list)}}))) + ## Nested (^ [_ (#Tuple (list& [_ (#Identifier ["" m-name])] extra))]) (do Monad<Meta> [import-name (clean-module nested? relative-root m-name) @@ -4311,10 +4307,25 @@ #refer-open openings}} sub-imports))) - (^ [_ (#Record (list [[_ (#Tuple (list [_ (#Int alteration)] [_ (#Text domain)]))] + ## Parallel + (^ [_ (#Record (list [[_ (#Tuple (list [_ (#Nat alteration)] + [_ (#Tag ["" domain])]))] + parallel-tree]))]) + (do Monad<Meta> + [parallel-imports (parse-imports nested? relative-root (list parallel-tree))] + (wrap (list/map (alter-domain alteration domain) parallel-imports))) + + (^ [_ (#Record (list [[_ (#Nat alteration)] parallel-tree]))]) (do Monad<Meta> [parallel-imports (parse-imports nested? relative-root (list parallel-tree))] + (wrap (list/map (alter-domain alteration "") parallel-imports))) + + (^ [_ (#Record (list [[_ (#Tag ["" domain])] + parallel-tree]))]) + (do Monad<Meta> + [parallel-imports (parse-imports nested? relative-root (list parallel-tree)) + #let [alteration (list/size (text/split-all-with ..module-separator domain))]] (wrap (list/map (alter-domain alteration domain) parallel-imports))) _ |