From 2607c95980e87f5f270e1fe6eaf7a7b3311ca138 Mon Sep 17 00:00:00 2001
From: Eduardo Julian
Date: Sun, 3 Feb 2019 01:38:44 -0400
Subject: Improved syntax for domains/parallel-import-trees.
---
stdlib/source/lux.lux | 41 ++++++++++++++++++++++++++---------------
1 file changed, 26 insertions(+), 15 deletions(-)
(limited to 'stdlib/source/lux.lux')
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
[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
[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
+ [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
[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
+ [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)))
_
--
cgit v1.2.3