aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2018-07-03 22:20:22 -0400
committerEduardo Julian2018-07-03 22:20:22 -0400
commitf505b42847bd7ba54b14d4b593b883c1bb25501d (patch)
treeeb017a0f3db7d4cd7dee260dd5eb437ad74f327a /stdlib
parent371a407a49ddf0f2fe1d977018fcd0a009c86043 (diff)
- Re-named "sequence" to "row".
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/data/coll/row.lux (renamed from stdlib/source/lux/data/coll/sequence.lux)75
-rw-r--r--stdlib/source/lux/data/format/json.lux22
-rw-r--r--stdlib/source/lux/lang/compiler/translation.lux8
-rw-r--r--stdlib/source/lux/lang/syntax.lux18
-rw-r--r--stdlib/source/lux/macro/poly/equality.lux4
-rw-r--r--stdlib/source/lux/macro/poly/json.lux8
-rw-r--r--stdlib/source/lux/math/random.lux20
-rw-r--r--stdlib/source/lux/time/date.lux18
-rw-r--r--stdlib/source/lux/time/instant.lux50
-rw-r--r--stdlib/source/lux/type/resource.lux8
-rw-r--r--stdlib/test/test/lux/data/coll/row.lux (renamed from stdlib/test/test/lux/data/coll/sequence.lux)38
-rw-r--r--stdlib/test/test/lux/data/format/json.lux4
-rw-r--r--stdlib/test/test/lux/math/random.lux22
13 files changed, 147 insertions, 148 deletions
diff --git a/stdlib/source/lux/data/coll/sequence.lux b/stdlib/source/lux/data/coll/row.lux
index 4e6226dcd..0b258a2ec 100644
--- a/stdlib/source/lux/data/coll/sequence.lux
+++ b/stdlib/source/lux/data/coll/row.lux
@@ -169,7 +169,7 @@
#.Nil))))
## [Types]
-(type: #export (Sequence a)
+(type: #export (Row a)
{#level Level
#size Nat
#root (Hierarchy a)
@@ -177,18 +177,18 @@
## [Exports]
(def: #export empty
- Sequence
+ Row
{#level (level-up root-level)
#size +0
#root (array.new full-node-size)
#tail (array.new +0)})
-(def: #export (size sequence)
- (All [a] (-> (Sequence a) Nat))
- (get@ #size sequence))
+(def: #export (size row)
+ (All [a] (-> (Row a) Nat))
+ (get@ #size row))
(def: #export (add val vec)
- (All [a] (-> a (Sequence a) (Sequence a)))
+ (All [a] (-> a (Row a) (Row a)))
## Check if there is room in the tail.
(let [vec-size (get@ #size vec)]
(if (|> vec-size (n/- (tail-off vec-size)) (n/< full-node-size))
@@ -214,14 +214,14 @@
## Otherwise, just push the current tail onto the root.
(|> vec
(update@ #root (push-tail vec-size (get@ #level vec) (get@ #tail vec)))))
- ## Finally, update the size of the Sequence and grow a new
+ ## Finally, update the size of the row and grow a new
## tail with the new element as it's sole member.
(update@ #size inc)
(set@ #tail (new-tail val)))
)))
(def: (base-for idx vec)
- (All [a] (-> Index (Sequence a) (Maybe (Base a))))
+ (All [a] (-> Index (Row a) (Maybe (Base a))))
(let [vec-size (get@ #size vec)]
(if (and (n/>= +0 idx)
(n/< vec-size idx))
@@ -241,17 +241,17 @@
#.None
_
- (error! "Incorrect sequence structure."))))
+ (error! "Incorrect row structure."))))
#.None)))
(def: #export (nth idx vec)
- (All [a] (-> Nat (Sequence a) (Maybe a)))
+ (All [a] (-> Nat (Row a) (Maybe a)))
(do maybe.Monad<Maybe>
[base (base-for idx vec)]
(array.read (branch-idx idx) base)))
(def: #export (put idx val vec)
- (All [a] (-> Nat a (Sequence a) (Sequence a)))
+ (All [a] (-> Nat a (Row a) (Row a)))
(let [vec-size (get@ #size vec)]
(if (and (n/>= +0 idx)
(n/< vec-size idx))
@@ -267,7 +267,7 @@
vec)))
(def: #export (update idx f vec)
- (All [a] (-> Nat (-> a a) (Sequence a) (Sequence a)))
+ (All [a] (-> Nat (-> a a) (Row a) (Row a)))
(case (nth idx vec)
(#.Some val)
(put idx (f val) vec)
@@ -276,7 +276,7 @@
vec))
(def: #export (pop vec)
- (All [a] (-> (Sequence a) (Sequence a)))
+ (All [a] (-> (Row a) (Row a)))
(case (get@ #size vec)
+0
empty
@@ -318,28 +318,28 @@
))
(def: #export (to-list vec)
- (All [a] (-> (Sequence a) (List a)))
+ (All [a] (-> (Row a) (List a)))
(list/compose (to-list' (#Hierarchy (get@ #root vec)))
(to-list' (#Base (get@ #tail vec)))))
(def: #export (from-list list)
- (All [a] (-> (List a) (Sequence a)))
+ (All [a] (-> (List a) (Row a)))
(list/fold add
empty
list))
(def: #export (member? a/Eq vec val)
- (All [a] (-> (Eq a) (Sequence a) a Bool))
+ (All [a] (-> (Eq a) (Row a) a Bool))
(list.member? a/Eq (to-list vec) val))
(def: #export empty?
- (All [a] (-> (Sequence a) Bool))
+ (All [a] (-> (Row a) Bool))
(|>> (get@ #size) (n/= +0)))
## [Syntax]
-(syntax: #export (sequence {elems (p.some s.any)})
- {#.doc (doc "Sequence literals."
- (sequence 10 20 30 40))}
+(syntax: #export (row {elems (p.some s.any)})
+ {#.doc (doc "Row literals."
+ (row 10 20 30 40))}
(wrap (list (` (from-list (list (~+ elems)))))))
## [Structures]
@@ -355,7 +355,7 @@
_
false)))
-(struct: #export (Eq<Sequence> Eq<a>) (All [a] (-> (Eq a) (Eq (Sequence a))))
+(struct: #export (Eq<Row> Eq<a>) (All [a] (-> (Eq a) (Eq (Row a))))
(def: (= v1 v2)
(and (n/= (get@ #size v1) (get@ #size v2))
(let [(^open "Node/") (Eq<Node> Eq<a>)]
@@ -376,7 +376,7 @@
hierarchy))
))
-(struct: #export _ (Fold Sequence)
+(struct: #export _ (Fold Row)
(def: (fold f init xs)
(let [(^open) Fold<Node>]
(fold f
@@ -386,8 +386,7 @@
(#Base (get@ #tail xs))))
))
-(struct: #export Monoid<Sequence> (All [a]
- (Monoid (Sequence a)))
+(struct: #export Monoid<Row> (All [a] (Monoid (Row a)))
(def: identity empty)
(def: (compose xs ys)
(list/fold add xs (to-list ys))))
@@ -402,7 +401,7 @@
(#Hierarchy (array/map (map f) hierarchy)))
))
-(struct: #export _ (Functor Sequence)
+(struct: #export _ (Functor Row)
(def: (map f xs)
{#level (get@ #level xs)
#size (get@ #size xs)
@@ -410,29 +409,29 @@
#tail (|> xs (get@ #tail) (array/map f))
}))
-(struct: #export _ (Apply Sequence)
- (def: functor Functor<Sequence>)
+(struct: #export _ (Apply Row)
+ (def: functor Functor<Row>)
(def: (apply ff fa)
- (let [(^open) Functor<Sequence>
- (^open) Fold<Sequence>
- (^open) Monoid<Sequence>
+ (let [(^open) Functor<Row>
+ (^open) Fold<Row>
+ (^open) Monoid<Row>
results (map (function (_ f) (map f fa))
ff)]
(fold compose identity results))))
-(struct: #export _ (Monad Sequence)
- (def: functor Functor<Sequence>)
+(struct: #export _ (Monad Row)
+ (def: functor Functor<Row>)
- (def: wrap (|>> sequence))
+ (def: wrap (|>> row))
(def: join
- (let [(^open) Fold<Sequence>
- (^open) Monoid<Sequence>]
+ (let [(^open) Fold<Row>
+ (^open) Monoid<Row>]
(fold (function (_ post pre) (compose pre post)) identity))))
(def: #export (reverse xs)
- (All [a] (-> (Sequence a) (Sequence a)))
- (let [(^open) Fold<Sequence>
- (^open) Monoid<Sequence>]
+ (All [a] (-> (Row a) (Row a)))
+ (let [(^open) Fold<Row>
+ (^open) Monoid<Row>]
(fold add identity xs)))
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index 9262c3d70..a5c81ad6b 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -15,7 +15,7 @@
[sum]
[product]
(coll [list "list/" Fold<List> Monad<List>]
- [sequence #+ Sequence sequence "sequence/" Monad<Sequence>]
+ [row #+ Row row "row/" Monad<Row>]
(dictionary ["dict" unordered #+ Dict])))
[macro #+ Monad<Meta> with-gensyms]
(macro ["s" syntax #+ syntax:]
@@ -35,13 +35,13 @@
(#Boolean Boolean)
(#Number Number)
(#String String)
- (#Array (Sequence JSON))
+ (#Array (Row JSON))
(#Object (Dict String JSON)))
(do-template [<name> <type>]
[(type: #export <name> <type>)]
- [Array (Sequence JSON)]
+ [Array (Row JSON)]
[Object (Dict String JSON)]
)
@@ -72,7 +72,7 @@
(wrap (list (` (: JSON #Null))))
[_ (#.Tuple members)]
- (wrap (list (` (: JSON (#Array (sequence (~+ (list/map wrapper members))))))))
+ (wrap (list (` (: JSON (#Array (row (~+ (list/map wrapper members))))))))
[_ (#.Record pairs)]
(do Monad<Meta>
@@ -161,16 +161,16 @@
[#String text.Eq<Text>])
[(#Array xs) (#Array ys)]
- (and (n/= (sequence.size xs) (sequence.size ys))
+ (and (n/= (row.size xs) (row.size ys))
(list/fold (function (_ idx prev)
(and prev
(maybe.default false
(do maybe.Monad<Maybe>
- [x' (sequence.nth idx xs)
- y' (sequence.nth idx ys)]
+ [x' (row.nth idx xs)
+ y' (row.nth idx ys)]
(wrap (= x' y'))))))
true
- (list.indices (sequence.size xs))))
+ (list.indices (row.size xs))))
[(#Object xs) (#Object ys)]
(and (n/= (dict.size xs) (dict.size ys))
@@ -285,7 +285,7 @@
[head any]
(case head
(#Array values)
- (case (p.run (sequence.to-list values) parser)
+ (case (p.run (row.to-list values) parser)
(#e.Error error)
(fail error)
@@ -364,7 +364,7 @@
(def: (show-array show-json elems)
(-> (-> JSON Text) (-> Array Text))
($_ text/compose "["
- (|> elems (sequence/map show-json) sequence.to-list (text.join-with ","))
+ (|> elems (row/map show-json) row.to-list (text.join-with ","))
"]"))
(def: (show-object show-json object)
@@ -487,7 +487,7 @@
_ (l.this <close>)]
(wrap (<prep> elems))))]
- [array~ Array "[" "]" (json~ []) sequence.from-list]
+ [array~ Array "[" "]" (json~ []) row.from-list]
[object~ Object "{" "}" (kv~ json~) (dict.from-list text.Hash<Text>)]
)
diff --git a/stdlib/source/lux/lang/compiler/translation.lux b/stdlib/source/lux/lang/compiler/translation.lux
index c117bc019..d5a6fb255 100644
--- a/stdlib/source/lux/lang/compiler/translation.lux
+++ b/stdlib/source/lux/lang/compiler/translation.lux
@@ -6,7 +6,7 @@
[error #+ Error]
[text]
text/format
- (coll [sequence #+ Sequence]
+ (coll [row #+ Row]
(dictionary ["dict" unordered #+ Dict])))
(world [file #+ File]))
[//name]
@@ -35,7 +35,7 @@
(: (-> code (Error Any))
evaluate!))
-(type: #export (Buffer code) (Sequence [Ident code]))
+(type: #export (Buffer code) (Row [Ident code]))
(type: #export (Artifacts code) (Dict File (Buffer code)))
@@ -117,7 +117,7 @@
with-buffer
(-> (Operation (..State anchor code) output)
(Operation (..State anchor code) output))
- sequence.empty
+ row.empty
buffer (Buffer code) no-active-buffer]
)
@@ -150,7 +150,7 @@
[_ (execute! code)]
(function (_ state)
(#error.Success [(update@ #buffer
- (maybe/map (sequence.add [name code]))
+ (maybe/map (row.add [name code]))
state)
[]]))))
diff --git a/stdlib/source/lux/lang/syntax.lux b/stdlib/source/lux/lang/syntax.lux
index 8029b5975..bbbd19232 100644
--- a/stdlib/source/lux/lang/syntax.lux
+++ b/stdlib/source/lux/lang/syntax.lux
@@ -36,7 +36,7 @@
[text]
(text ["l" lexer]
format)
- (coll [sequence #+ Sequence]
+ (coll [row #+ Row]
(dictionary ["dict" unordered #+ Dict])))))
(type: #export Aliases (Dict Text Text))
@@ -424,14 +424,14 @@
(l.Lexer [Cursor Code]))
(do p.Monad<Parser>
[_ (l.this <open>)
- [where' elems] (loop [elems (: (Sequence Code)
- sequence.empty)
+ [where' elems] (loop [elems (: (Row Code)
+ row.empty)
where where]
(p.either (do @
[## Must update the cursor as I
## go along, to keep things accurate.
[where' elem] (ast where)]
- (recur (sequence.add elem elems)
+ (recur (row.add elem elems)
where'))
(do @
[## Must take into account any
@@ -440,7 +440,7 @@
where' (left-padding^ where)
_ (l.this <close>)]
(wrap [(update@ #.column inc where')
- (sequence.to-list elems)]))))]
+ (row.to-list elems)]))))]
(wrap [where'
[where (<tag> elems)]])))]
@@ -463,19 +463,19 @@
(l.Lexer [Cursor Code]))
(do p.Monad<Parser>
[_ (l.this "{")
- [where' elems] (loop [elems (: (Sequence [Code Code])
- sequence.empty)
+ [where' elems] (loop [elems (: (Row [Code Code])
+ row.empty)
where where]
(p.either (do @
[[where' key] (ast where)
[where' val] (ast where')]
- (recur (sequence.add [key val] elems)
+ (recur (row.add [key val] elems)
where'))
(do @
[where' (left-padding^ where)
_ (l.this "}")]
(wrap [(update@ #.column inc where')
- (sequence.to-list elems)]))))]
+ (row.to-list elems)]))))]
(wrap [where'
[where (#.Record elems)]])))
diff --git a/stdlib/source/lux/macro/poly/equality.lux b/stdlib/source/lux/macro/poly/equality.lux
index 8df347bba..bdf70d622 100644
--- a/stdlib/source/lux/macro/poly/equality.lux
+++ b/stdlib/source/lux/macro/poly/equality.lux
@@ -6,7 +6,7 @@
(data [text "text/" Monoid<Text>]
text/format
(coll [list "list/" Monad<List>]
- [sequence]
+ [row]
[array]
[queue]
(set ["set" unordered])
@@ -62,7 +62,7 @@
[.Maybe maybe.Eq<Maybe>]
[.List list.Eq<List>]
- [sequence.Sequence sequence.Eq<Sequence>]
+ [row.Row row.Eq<Row>]
[.Array array.Eq<Array>]
[queue.Queue queue.Eq<Queue>]
[set.Set set.Eq<Set>]
diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux
index ba20f7627..ba8512835 100644
--- a/stdlib/source/lux/macro/poly/json.lux
+++ b/stdlib/source/lux/macro/poly/json.lux
@@ -15,7 +15,7 @@
[sum]
[product]
(coll [list "list/" Fold<List> Monad<List>]
- [sequence #+ Sequence sequence "sequence/" Monad<Sequence>]
+ [row #+ Row row "row/" Monad<Row>]
(dictionary ["d" unordered]))
(format ["//" json #+ JSON]))
(time ## ["i" instant]
@@ -47,8 +47,8 @@
(def: (encode input)
(let [high (|> input (bit.and high-mask) (bit.logical-right-shift +32))
low (bit.and low-mask input)]
- (#//.Array (sequence (|> high .int int-to-frac #//.Number)
- (|> low .int int-to-frac #//.Number)))))
+ (#//.Array (row (|> high .int int-to-frac #//.Number)
+ (|> low .int int-to-frac #//.Number)))))
(def: (decode input)
(<| (//.run input)
//.array
@@ -143,7 +143,7 @@
(poly.this .List)
Codec<JSON,?>//encode))]
(wrap (` (: (~ (@JSON//encode inputT))
- (|>> ((~! list/map) (~ =sub=)) sequence.from-list #//.Array)))))
+ (|>> ((~! list/map) (~ =sub=)) row.from-list #//.Array)))))
(do @
[#let [g!_ (code.local-symbol "_______")
g!input (code.local-symbol "_______input")]
diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux
index 55c504585..b8db79ccb 100644
--- a/stdlib/source/lux/math/random.lux
+++ b/stdlib/source/lux/math/random.lux
@@ -18,7 +18,7 @@
[queue #+ Queue]
(set ["set" unordered #+ Set])
[stack #+ Stack]
- [sequence #+ Sequence]
+ [row #+ Row]
(tree [finger #+ Tree])))
))
@@ -194,7 +194,7 @@
(:: Monad<Random> wrap <zero>)))]
[list List (.list) #.Cons]
- [sequence Sequence sequence.empty sequence.add]
+ [row Row row.empty row.add]
)
(do-template [<name> <type> <ctor>]
@@ -274,21 +274,21 @@
("lux i64 +" s0 s1)]))
(def: (swap from to vec)
- (All [a] (-> Nat Nat (Sequence a) (Sequence a)))
+ (All [a] (-> Nat Nat (Row a) (Row a)))
(|> vec
- (sequence.put to (maybe.assume (sequence.nth from vec)))
- (sequence.put from (maybe.assume (sequence.nth to vec)))))
+ (row.put to (maybe.assume (row.nth from vec)))
+ (row.put from (maybe.assume (row.nth to vec)))))
-(def: #export (shuffle seed sequence)
- {#.doc "Shuffle a sequence randomly based on a seed value."}
- (All [a] (-> Nat (Sequence a) (Sequence a)))
- (let [_size (sequence.size sequence)
+(def: #export (shuffle seed row)
+ {#.doc "Shuffle a row randomly based on a seed value."}
+ (All [a] (-> Nat (Row a) (Row a)))
+ (let [_size (row.size row)
_shuffle (monad.fold Monad<Random>
(function (_ idx vec)
(do Monad<Random>
[rand nat]
(wrap (swap idx (n/% _size rand) vec))))
- sequence
+ row
(list.n/range +0 (dec _size)))]
(|> _shuffle
(run (pcg-32 [+123 seed]))
diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux
index 89f906040..2a937c84d 100644
--- a/stdlib/source/lux/time/date.lux
+++ b/stdlib/source/lux/time/date.lux
@@ -11,7 +11,7 @@
[number "int/" Codec<Text,Int>]
[text "text/" Monoid<Text>]
(text ["l" lexer])
- (coll [sequence #+ Sequence sequence]))))
+ (coll [row #+ Row row]))))
(type: #export Year Int)
@@ -252,15 +252,15 @@
(i/+ (i// 400 year))))
(def: normal-months
- (Sequence Nat)
- (sequence +31 +28 +31
- +30 +31 +30
- +31 +31 +30
- +31 +30 +31))
+ (Row Nat)
+ (row +31 +28 +31
+ +30 +31 +30
+ +31 +31 +30
+ +31 +30 +31))
(def: leap-year-months
- (Sequence Nat)
- (sequence.update [+1] inc normal-months))
+ (Row Nat)
+ (row.update [+1] inc normal-months))
(def: (divisible? factor input)
(-> Int Int Bool)
@@ -286,7 +286,7 @@
leap-year-months
normal-months)
month-days (|> months
- (sequence.nth (.nat (dec utc-month)))
+ (row.nth (.nat (dec utc-month)))
maybe.assume)]
_ (l.this "-")
utc-day lex-section
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux
index 1a2af827e..68a86bf9d 100644
--- a/stdlib/source/lux/time/instant.lux
+++ b/stdlib/source/lux/time/instant.lux
@@ -13,7 +13,7 @@
["e" error]
[maybe]
(coll [list "L/" Fold<List> Functor<List>]
- [sequence #+ Sequence sequence "sequence/" Functor<Sequence> Fold<Sequence>]))
+ [row #+ Row row "row/" Functor<Row> Fold<Row>]))
(type abstract))
(// [duration "duration/" Order<Duration>]
[date]))
@@ -102,33 +102,33 @@
))))
(def: normal-months
- (Sequence Nat)
- (sequence +31 +28 +31
- +30 +31 +30
- +31 +31 +30
- +31 +30 +31))
+ (Row Nat)
+ (row +31 +28 +31
+ +30 +31 +30
+ +31 +31 +30
+ +31 +30 +31))
(def: leap-year-months
- (Sequence Nat)
- (sequence.update [+1] inc normal-months))
+ (Row Nat)
+ (row.update [+1] inc normal-months))
(def: (find-month months time)
- (-> (Sequence Nat) duration.Duration [Nat duration.Duration])
+ (-> (Row Nat) duration.Duration [Nat duration.Duration])
(if (duration/>= duration.empty time)
- (sequence/fold (function (_ month-days [current-month time-left])
- (let [month-duration (duration.scale (.int month-days) duration.day)]
- (if (i/= 0 (duration.query month-duration time-left))
- [current-month time-left]
- [(inc current-month) (duration.merge (duration.scale -1 month-duration) time-left)])))
- [+0 time]
- months)
- (sequence/fold (function (_ month-days [current-month time-left])
- (let [month-duration (duration.scale (.int month-days) duration.day)]
- (if (i/= 0 (duration.query month-duration time-left))
- [current-month time-left]
- [(dec current-month) (duration.merge month-duration time-left)])))
- [+11 time]
- (sequence.reverse months))))
+ (row/fold (function (_ month-days [current-month time-left])
+ (let [month-duration (duration.scale (.int month-days) duration.day)]
+ (if (i/= 0 (duration.query month-duration time-left))
+ [current-month time-left]
+ [(inc current-month) (duration.merge (duration.scale -1 month-duration) time-left)])))
+ [+0 time]
+ months)
+ (row/fold (function (_ month-days [current-month time-left])
+ (let [month-duration (duration.scale (.int month-days) duration.day)]
+ (if (i/= 0 (duration.query month-duration time-left))
+ [current-month time-left]
+ [(dec current-month) (duration.merge month-duration time-left)])))
+ [+11 time]
+ (row.reverse months))))
(def: (pad value)
(-> Int Text)
@@ -251,7 +251,7 @@
leap-year-months
normal-months)
month-days (|> months
- (sequence.nth (.nat (dec utc-month)))
+ (row.nth (.nat (dec utc-month)))
maybe.assume)]
_ (l.this "-")
utc-day lex-section
@@ -281,7 +281,7 @@
year-days-so-far (|> (i/* 365 years-since-epoch)
(i/+ previous-leap-days))
month-days-so-far (|> months
- sequence.to-list
+ row.to-list
(list.take (.nat (dec utc-month)))
(L/fold n/+ +0))
total-days (|> year-days-so-far
diff --git a/stdlib/source/lux/type/resource.lux b/stdlib/source/lux/type/resource.lux
index eafda2092..ea86f45e8 100644
--- a/stdlib/source/lux/type/resource.lux
+++ b/stdlib/source/lux/type/resource.lux
@@ -11,7 +11,7 @@
text/format
(coll (dictionary ["dict" unordered #+ Dict])
(set ["set" unordered])
- [sequence #+ Sequence]
+ [row #+ Row]
[list "list/" Functor<List> Fold<List>]))
(concurrency [promise #+ Promise])
[macro]
@@ -155,11 +155,11 @@
(function (_ from to)
(do maybe.Monad<Maybe>
[input (list.nth from g!inputs)]
- (wrap (sequence.add input to))))
- (: (Sequence Code) sequence.empty)
+ (wrap (row.add input to))))
+ (: (Row Code) row.empty)
swaps)
maybe.assume
- sequence.to-list)
+ row.to-list)
g!inputsT+ (list/map (|>> (~) ..CK (`)) g!inputs)
g!outputsT+ (list/map (|>> (~) ..CK (`)) g!outputs)]]
(wrap (list (` (: (All [(~+ g!inputs) (~ g!context)]
diff --git a/stdlib/test/test/lux/data/coll/sequence.lux b/stdlib/test/test/lux/data/coll/row.lux
index 024e91c6b..3a4da0f42 100644
--- a/stdlib/test/test/lux/data/coll/sequence.lux
+++ b/stdlib/test/test/lux/data/coll/row.lux
@@ -2,45 +2,45 @@
lux
(lux [io]
(control [monad #+ do Monad])
- (data (coll ["&" sequence]
+ (data (coll ["&" row]
[list "list/" Fold<List>])
[number]
[maybe])
["r" math/random])
lux/test)
-(context: "Sequences"
+(context: "Rows"
(<| (times +100)
(do @
[size (|> r.nat (:: @ map (|>> (n/% +100) (n/max +1))))
idx (|> r.nat (:: @ map (n/% size)))
- sample (r.sequence size r.nat)
- other-sample (r.sequence size r.nat)
+ sample (r.row size r.nat)
+ other-sample (r.row size r.nat)
non-member (|> r.nat (r.filter (|>> (&.member? number.Eq<Nat> sample) not)))
- #let [(^open "&/") (&.Eq<Sequence> number.Eq<Nat>)
- (^open "&/") &.Apply<Sequence>
- (^open "&/") &.Monad<Sequence>
- (^open "&/") &.Fold<Sequence>
- (^open "&/") &.Monoid<Sequence>]]
+ #let [(^open "&/") (&.Eq<Row> number.Eq<Nat>)
+ (^open "&/") &.Apply<Row>
+ (^open "&/") &.Monad<Row>
+ (^open "&/") &.Fold<Row>
+ (^open "&/") &.Monoid<Row>]]
($_ seq
- (test "Can query size of sequence."
+ (test "Can query size of row."
(if (&.empty? sample)
(and (n/= +0 size)
(n/= +0 (&.size sample)))
(n/= size (&.size sample))))
- (test "Can add and remove elements to sequences."
+ (test "Can add and remove elements to rows."
(and (n/= (inc size) (&.size (&.add non-member sample)))
(n/= (dec size) (&.size (&.pop sample)))))
- (test "Can put and get elements into sequences."
+ (test "Can put and get elements into rows."
(|> sample
(&.put idx non-member)
(&.nth idx)
maybe.assume
(is? non-member)))
- (test "Can update elements of sequences."
+ (test "Can update elements of rows."
(|> sample
(&.put idx non-member) (&.update idx inc)
(&.nth idx) maybe.assume
@@ -49,11 +49,11 @@
(test "Can safely transform to/from lists."
(|> sample &.to-list &.from-list (&/= sample)))
- (test "Can identify members of a sequence."
+ (test "Can identify members of a row."
(and (not (&.member? number.Eq<Nat> sample non-member))
(&.member? number.Eq<Nat> (&.add non-member sample) non-member)))
- (test "Can fold over elements of sequence."
+ (test "Can fold over elements of row."
(n/= (list/fold n/+ +0 (&.to-list sample))
(&/fold n/+ +0 sample)))
@@ -63,11 +63,11 @@
(and (not (&/= sample there))
(&/= sample back-again))))
- (test "Apply allows you to create singleton sequences, and apply sequences of functions to sequences of values."
- (and (&/= (&.sequence non-member) (&/wrap non-member))
+ (test "Apply allows you to create singleton rows, and apply rows of functions to rows of values."
+ (and (&/= (&.row non-member) (&/wrap non-member))
(&/= (&/map inc sample) (&/apply (&/wrap inc) sample))))
- (test "Sequence concatenation is a monad."
+ (test "Row concatenation is a monad."
(&/= (&/compose sample other-sample)
- (&/join (&.sequence sample other-sample))))
+ (&/join (&.row sample other-sample))))
))))
diff --git a/stdlib/test/test/lux/data/format/json.lux b/stdlib/test/test/lux/data/format/json.lux
index a8a117a04..b3196e1e6 100644
--- a/stdlib/test/test/lux/data/format/json.lux
+++ b/stdlib/test/test/lux/data/format/json.lux
@@ -13,7 +13,7 @@
[maybe]
[number]
(format ["@" json])
- (coll [sequence #+ sequence]
+ (coll [row #+ row]
(dictionary ["d" unordered])
[list]))
[macro #+ with-gensyms]
@@ -43,7 +43,7 @@
r.bool
(|> r.frac (:: @ map (f/* 1_000_000.0)))
(r.unicode size)
- (r.sequence size gen-json)
+ (r.row size gen-json)
(r.dict text.Hash<Text> size (r.unicode size) gen-json)
)))))
diff --git a/stdlib/test/test/lux/math/random.lux b/stdlib/test/test/lux/math/random.lux
index 4230f27b1..b2f4fe6ca 100644
--- a/stdlib/test/test/lux/math/random.lux
+++ b/stdlib/test/test/lux/math/random.lux
@@ -5,7 +5,7 @@
(data [number]
text/format
(coll [list]
- [sequence]
+ [row]
[array]
[queue]
[stack]
@@ -19,7 +19,7 @@
(do @
[size (|> r.nat (:: @ map (|>> (n/% +100) (n/max +10))))
_list (r.list size r.nat)
- _sequence (r.sequence size r.nat)
+ _row (r.row size r.nat)
_array (r.array size r.nat)
_queue (r.queue size r.nat)
_stack (r.stack size r.nat)
@@ -28,14 +28,14 @@
top r.nat
filtered (|> r.nat (r.filter (n/<= top)))
shuffle-seed r.nat
- #let [sorted (|> _sequence sequence.to-list (list.sort n/<))
- shuffled (|> sorted sequence.from-list (r.shuffle shuffle-seed))
- re-sorted (|> shuffled sequence.to-list (list.sort n/<))]]
+ #let [sorted (|> _row row.to-list (list.sort n/<))
+ shuffled (|> sorted row.from-list (r.shuffle shuffle-seed))
+ re-sorted (|> shuffled row.to-list (list.sort n/<))]]
($_ seq
(test "Can produce lists."
(n/= size (list.size _list)))
- (test "Can produce sequences."
- (n/= size (sequence.size _sequence)))
+ (test "Can produce rows."
+ (n/= size (row.size _row)))
(test "Can produce arrays."
(n/= size (array.size _array)))
(test "Can produce queues."
@@ -48,9 +48,9 @@
(n/= size (dict.size _dict)))
(test "Can filter values."
(n/<= top filtered))
- (test "Can shuffle sequences."
- (let [(^open "v/") (sequence.Eq<Sequence> number.Eq<Nat>)
- sorted (sequence.from-list sorted)]
+ (test "Can shuffle rows."
+ (let [(^open "v/") (row.Eq<Row> number.Eq<Nat>)
+ sorted (row.from-list sorted)]
(and (not (v/= sorted shuffled))
- (v/= sorted (sequence.from-list re-sorted)))))
+ (v/= sorted (row.from-list re-sorted)))))
))))