diff options
-rw-r--r-- | stdlib/source/lux.lux | 41 | ||||
-rw-r--r-- | stdlib/test/test/lux.lux | 10 | ||||
-rw-r--r-- | stdlib/test/test/lux/cli.lux | 2 | ||||
-rw-r--r-- | stdlib/test/test/lux/data/maybe.lux | 17 | ||||
-rw-r--r-- | stdlib/test/test/lux/host.jvm.lux | 2 | ||||
-rw-r--r-- | stdlib/test/test/lux/host/jvm.jvm.lux | 2 |
6 files changed, 44 insertions, 30 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))) _ diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux index 4be4b753b..72b9f45ef 100644 --- a/stdlib/test/test/lux.lux +++ b/stdlib/test/test/lux.lux @@ -4,7 +4,6 @@ [monad (#+ do)] [predicate (#+ Predicate)]] [data - ["." maybe] [number ["." i64]]] ["." math @@ -155,15 +154,6 @@ _ false)))) - (do r.Monad<Random> - [default r.nat - maybe r.nat] - (_.test "Can have defaults for Maybe values." - (and (is? default (maybe.default default - #.None)) - - (is? maybe (maybe.default default - (#.Some maybe)))))) )) (template: (hypotenuse cat0 cat1) diff --git a/stdlib/test/test/lux/cli.lux b/stdlib/test/test/lux/cli.lux index 7c50a679b..0ee1071e8 100644 --- a/stdlib/test/test/lux/cli.lux +++ b/stdlib/test/test/lux/cli.lux @@ -14,7 +14,7 @@ [math ["r" random]] ["_" test (#+ Test)]] - {[-1 ""] + {1 ["." /]}) (def: #export test diff --git a/stdlib/test/test/lux/data/maybe.lux b/stdlib/test/test/lux/data/maybe.lux index 4f135b68a..d47559d62 100644 --- a/stdlib/test/test/lux/data/maybe.lux +++ b/stdlib/test/test/lux/data/maybe.lux @@ -43,6 +43,16 @@ a (wrap "yolo") b (wrap "lol")] (wrap (f a b))))) + + (do r.Monad<Random> + [default r.nat + maybe r.nat] + (_.test "Can have defaults for Maybe values." + (and (is? default (maybe.default default + #.None)) + + (is? maybe (maybe.default default + (#.Some maybe)))))) ))) (context: "Monad transformer" @@ -52,5 +62,8 @@ [a (lift (io/wrap +123)) b (wrap +456)] (wrap (i/+ a b)))) - (case> (#.Some +579) #1 - _ #0))))) + (case> (#.Some +579) + #1 + + _ + #0))))) diff --git a/stdlib/test/test/lux/host.jvm.lux b/stdlib/test/test/lux/host.jvm.lux index f1151f010..3e184c7b9 100644 --- a/stdlib/test/test/lux/host.jvm.lux +++ b/stdlib/test/test/lux/host.jvm.lux @@ -8,7 +8,7 @@ [math ["r" random]] ["_" test (#+ Test)]] - {[-1 ""] + {1 ["." / (#+ import: class: interface: object)]}) (import: (java/util/concurrent/Callable a)) diff --git a/stdlib/test/test/lux/host/jvm.jvm.lux b/stdlib/test/test/lux/host/jvm.jvm.lux index bacfd480b..2f5142e80 100644 --- a/stdlib/test/test/lux/host/jvm.jvm.lux +++ b/stdlib/test/test/lux/host/jvm.jvm.lux @@ -20,7 +20,7 @@ [math ["r" random]] ["_" test (#+ Test)]] - {[-1 ""] + {1 [/ ["/." loader (#+ Library)] ["/." version] |