aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/documentation/lux/data/collection.lux4
-rw-r--r--stdlib/source/documentation/lux/data/collection/stream.lux (renamed from stdlib/source/documentation/lux/data/collection/sequence.lux)27
-rw-r--r--stdlib/source/library/lux/data/collection/stream.lux (renamed from stdlib/source/library/lux/data/collection/sequence.lux)56
-rw-r--r--stdlib/source/library/lux/documentation.lux14
-rw-r--r--stdlib/source/test/lux/abstract/comonad/cofree.lux24
-rw-r--r--stdlib/source/test/lux/data/collection.lux4
-rw-r--r--stdlib/source/test/lux/data/collection/stream.lux (renamed from stdlib/source/test/lux/data/collection/sequence.lux)10
7 files changed, 69 insertions, 70 deletions
diff --git a/stdlib/source/documentation/lux/data/collection.lux b/stdlib/source/documentation/lux/data/collection.lux
index 7d4e0a6bc..9fae3d77f 100644
--- a/stdlib/source/documentation/lux/data/collection.lux
+++ b/stdlib/source/documentation/lux/data/collection.lux
@@ -14,7 +14,7 @@
["[1][0]" list]
["[1][0]" queue]
["[1][0]" row]
- ["[1][0]" sequence]
+ ["[1][0]" stream]
["[1][0]" stack]
["[1][0]" set]
["[1][0]" tree]])
@@ -28,7 +28,7 @@
/list.documentation
/queue.documentation
/row.documentation
- /sequence.documentation
+ /stream.documentation
/stack.documentation
/set.documentation
/tree.documentation
diff --git a/stdlib/source/documentation/lux/data/collection/sequence.lux b/stdlib/source/documentation/lux/data/collection/stream.lux
index 1bbf4db94..9486be114 100644
--- a/stdlib/source/documentation/lux/data/collection/sequence.lux
+++ b/stdlib/source/documentation/lux/data/collection/stream.lux
@@ -15,11 +15,11 @@
[\\library
["[0]" /]])
-(documentation: (/.Sequence it)
+(documentation: (/.Stream it)
"An infinite sequence of values.")
(documentation: /.iterations
- "A stateful way of infinitely calculating the values of a sequence."
+ "A stateful way of infinitely calculating the values of a stream."
[(iterations step init)])
(documentation: /.repeated
@@ -27,35 +27,34 @@
[(repeated x)])
(documentation: /.cycle
- (format "Go over the elements of a list forever."
- \n "The list should not be empty.")
+ "Go over the elements of a list forever."
[(cycle [start next])])
(documentation: /.item
""
- [(item idx sequence)])
+ [(item idx stream)])
(documentation: /.only
- "A new sequence only with items that satisfy the predicate."
- [(only predicate sequence)])
+ "A new stream only with items that satisfy the predicate."
+ [(only predicate stream)])
(documentation: /.partition
- (format "Split a sequence in two based on a predicate."
+ (format "Split a stream in two based on a predicate."
\n "The left side contains all entries for which the predicate is #1."
\n "The right side contains all entries for which the predicate is #0.")
[(partition left? xs)])
-(documentation: /.^sequence&
- (format "Allows destructuring of sequences in pattern-matching expressions."
- \n "Caveat emptor: Only use it for destructuring, and not for testing values within the sequences.")
- [(let [(^sequence& x y z _tail) (some_sequence_func +1 +2 +3)]
+(documentation: /.^stream&
+ (format "Allows destructuring of streams in pattern-matching expressions."
+ \n "Caveat emptor: Only use it for destructuring, and not for testing values within the streams.")
+ [(let [(^stream& x y z _tail) (some_stream_func +1 +2 +3)]
(func x y z))])
(.def: .public documentation
(.List $.Module)
($.module /._
""
- [..Sequence
+ [..Stream
..iterations
..repeated
..cycle
@@ -63,7 +62,7 @@
..only
..partition
- ..^sequence&
+ ..^stream&
($.default /.head)
($.default /.tail)
($.default /.functor)
diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/stream.lux
index fcfe2d0ed..f09423882 100644
--- a/stdlib/source/library/lux/data/collection/sequence.lux
+++ b/stdlib/source/library/lux/data/collection/stream.lux
@@ -19,23 +19,23 @@
[number
["n" nat]]]]])
-(type: .public (Sequence a)
- (Cont [a (Sequence a)]))
+(type: .public (Stream a)
+ (Cont [a (Stream a)]))
(def: .public (iterations step init)
(All (_ a b)
- (-> (-> a [a b]) a (Sequence b)))
+ (-> (-> a [a b]) a (Stream b)))
(let [[next x] (step init)]
(//.pending [x (iterations step next)])))
(def: .public (repeated x)
(All (_ a)
- (-> a (Sequence a)))
+ (-> a (Stream a)))
(//.pending [x (repeated x)]))
(def: .public (cycle [start next])
(All (_ a)
- (-> [a (List a)] (Sequence a)))
+ (-> [a (List a)] (Stream a)))
(loop [head start
tail next]
(//.pending [head (case tail
@@ -46,18 +46,18 @@
(again head' tail'))])))
(template [<name> <return>]
- [(def: .public (<name> sequence)
- (All (_ a) (-> (Sequence a) <return>))
- (let [[head tail] (//.result sequence)]
+ [(def: .public (<name> stream)
+ (All (_ a) (-> (Stream a) <return>))
+ (let [[head tail] (//.result stream)]
<name>))]
[head a]
- [tail (Sequence a)]
+ [tail (Stream a)]
)
-(def: .public (item idx sequence)
- (All (_ a) (-> Nat (Sequence a) a))
- (let [[head tail] (//.result sequence)]
+(def: .public (item idx stream)
+ (All (_ a) (-> Nat (Stream a) a))
+ (let [[head tail] (//.result stream)]
(case idx
0 head
_ (item (-- idx) tail))))
@@ -65,7 +65,7 @@
(template [<taker> <dropper> <pred_type> <pred_test> <pred_step> <post_test>]
[(def: .public (<taker> pred xs)
(All (_ a)
- (-> <pred_type> (Sequence a) (List a)))
+ (-> <pred_type> (Stream a) (List a)))
(let [[x xs'] (//.result xs)]
(if (<post_test> <pred_test>)
(list& x (<taker> <pred_step> xs'))
@@ -73,7 +73,7 @@
(def: .public (<dropper> pred xs)
(All (_ a)
- (-> <pred_type> (Sequence a) (Sequence a)))
+ (-> <pred_type> (Stream a) (Stream a)))
(let [[x xs'] (//.result xs)]
(if (<post_test> <pred_test>)
(<dropper> <pred_step> xs')
@@ -86,7 +86,7 @@
(template [<splitter> <pred_type> <pred_test> <pred_step>]
[(def: .public (<splitter> pred xs)
(All (_ a)
- (-> <pred_type> (Sequence a) [(List a) (Sequence a)]))
+ (-> <pred_type> (Stream a) [(List a) (Stream a)]))
(let [[x xs'] (//.result xs)]
(if <pred_test>
[(list) xs]
@@ -97,27 +97,27 @@
[split_at Nat (n.= 0 pred) (-- pred)]
)
-(def: .public (only predicate sequence)
- (All (_ a) (-> (-> a Bit) (Sequence a) (Sequence a)))
- (let [[head tail] (//.result sequence)]
+(def: .public (only predicate stream)
+ (All (_ a) (-> (-> a Bit) (Stream a) (Stream a)))
+ (let [[head tail] (//.result stream)]
(if (predicate head)
(//.pending [head (only predicate tail)])
(only predicate tail))))
(def: .public (partition left? xs)
- (All (_ a) (-> (-> a Bit) (Sequence a) [(Sequence a) (Sequence a)]))
+ (All (_ a) (-> (-> a Bit) (Stream a) [(Stream a) (Stream a)]))
[(..only left? xs)
(..only (bit.complement left?) xs)])
(implementation: .public functor
- (Functor Sequence)
+ (Functor Stream)
(def: (each f fa)
(let [[head tail] (//.result fa)]
(//.pending [(f head) (each f tail)]))))
(implementation: .public comonad
- (CoMonad Sequence)
+ (CoMonad Stream)
(def: &functor ..functor)
@@ -127,14 +127,14 @@
(let [[head tail] (//.result wa)]
(//.pending [wa (disjoint tail)]))))
-(syntax: .public (^sequence& [patterns (<code>.form (<>.many <code>.any))
- body <code>.any
- branches (<>.some <code>.any)])
- (with_symbols [g!sequence]
+(syntax: .public (^stream& [patterns (<code>.form (<>.many <code>.any))
+ body <code>.any
+ branches (<>.some <code>.any)])
+ (with_symbols [g!stream]
(let [body+ (` (let [(~+ (|> patterns
(list#each (function (_ pattern)
- (list (` [(~ pattern) (~ g!sequence)])
- (` ((~! //.result) (~ g!sequence))))))
+ (list (` [(~ pattern) (~ g!stream)])
+ (` ((~! //.result) (~ g!stream))))))
list#conjoint))]
(~ body)))]
- (in (list& g!sequence body+ branches)))))
+ (in (list& g!stream body+ branches)))))
diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux
index 5bd6f7f30..ec99259f9 100644
--- a/stdlib/source/library/lux/documentation.lux
+++ b/stdlib/source/library/lux/documentation.lux
@@ -18,7 +18,7 @@
[collection
["[0]" list ("[1]#[0]" monad mix monoid)]
["[0]" set {"+" Set}]
- ["[0]" sequence {"+" Sequence}]]
+ ["[0]" stream {"+" Stream}]]
[format
["md" markdown {"+" Markdown Block}]]]
["[0]" macro
@@ -165,9 +165,9 @@
)
(def: type_variable_names
- (Sequence Text)
- (sequence.iterations (product.forked ++ parameter_type_name)
- 0))
+ (Stream Text)
+ (stream.iterations (product.forked ++ parameter_type_name)
+ 0))
(template [<name> <partition>]
[(def: (<name> id)
@@ -193,9 +193,9 @@
_
(let [parameter_id (n.- (list.size type_function_arguments) parameter_id)]
(|> type_variable_names
- (sequence.only (function (_ var_name)
- (not (list.member? text.equivalence type_function_arguments var_name))))
- (sequence.item parameter_id)))))
+ (stream.only (function (_ var_name)
+ (not (list.member? text.equivalence type_function_arguments var_name))))
+ (stream.item parameter_id)))))
type_function_name))
(def: (level_parameters offset level)
diff --git a/stdlib/source/test/lux/abstract/comonad/cofree.lux b/stdlib/source/test/lux/abstract/comonad/cofree.lux
index dca4680de..285628356 100644
--- a/stdlib/source/test/lux/abstract/comonad/cofree.lux
+++ b/stdlib/source/test/lux/abstract/comonad/cofree.lux
@@ -13,29 +13,29 @@
[data
[collection
["[0]" list]
- ["[0]" sequence {"+" Sequence} ("[1]#[0]" comonad)]]]
+ ["[0]" stream {"+" Stream} ("[1]#[0]" comonad)]]]
[math
["[0]" random]]]]
[\\library
["[0]" /]])
(def: (injection value)
- (Injection (/.CoFree Sequence))
- [value (sequence#each injection (sequence.repeated value))])
+ (Injection (/.CoFree Stream))
+ [value (stream#each injection (stream.repeated value))])
(def: (interpret [head tail])
- (All (_ a) (-> (/.CoFree Sequence a) (Sequence a)))
+ (All (_ a) (-> (/.CoFree Stream a) (Stream a)))
(|> tail
- (sequence#each (# (/.comonad sequence.functor) out))
+ (stream#each (# (/.comonad stream.functor) out))
[head]
//.pending))
(def: comparison
- (Comparison (/.CoFree Sequence))
+ (Comparison (/.CoFree Stream))
(function (_ == left right)
(# (list.equivalence ==) =
- (sequence.first 100 (..interpret left))
- (sequence.first 100 (..interpret right)))))
+ (stream.first 100 (..interpret left))
+ (stream.first 100 (..interpret right)))))
(def: .public test
Test
@@ -43,9 +43,9 @@
(_.for [/.CoFree])
($_ _.and
(_.for [/.functor]
- ($functor.spec ..injection ..comparison (: (Functor (/.CoFree Sequence))
- (/.functor sequence.functor))))
+ ($functor.spec ..injection ..comparison (: (Functor (/.CoFree Stream))
+ (/.functor stream.functor))))
(_.for [/.comonad]
- ($comonad.spec ..injection ..comparison (: (CoMonad (/.CoFree Sequence))
- (/.comonad sequence.functor))))
+ ($comonad.spec ..injection ..comparison (: (CoMonad (/.CoFree Stream))
+ (/.comonad stream.functor))))
)))
diff --git a/stdlib/source/test/lux/data/collection.lux b/stdlib/source/test/lux/data/collection.lux
index 4d7de7ed5..e4caad8c8 100644
--- a/stdlib/source/test/lux/data/collection.lux
+++ b/stdlib/source/test/lux/data/collection.lux
@@ -7,7 +7,7 @@
["[1][0]" bits]
["[1][0]" list]
["[1][0]" row]
- ["[1][0]" sequence]
+ ["[1][0]" stream]
["[1][0]" stack]
["[1][0]" dictionary
["[1]/[0]" ordered]
@@ -59,7 +59,7 @@
/bits.test
/list.test
/row.test
- /sequence.test
+ /stream.test
/stack.test
..dictionary
..queue
diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/stream.lux
index 22dc1b37e..bd73a3204 100644
--- a/stdlib/source/test/lux/data/collection/sequence.lux
+++ b/stdlib/source/test/lux/data/collection/stream.lux
@@ -22,7 +22,7 @@
["[0]" /]])
(implementation: (equivalence super)
- (All (_ a) (-> (Equivalence a) (Equivalence (/.Sequence a))))
+ (All (_ a) (-> (Equivalence a) (Equivalence (/.Stream a))))
(def: (= reference subject)
(# (list.equivalence super) =
@@ -32,7 +32,7 @@
(def: (iterations step)
(All (_ a)
(-> (-> a a)
- (-> a (/.Sequence a))))
+ (-> a (/.Stream a))))
(/.iterations
(function (_ state)
(let [state' (step state)]
@@ -41,7 +41,7 @@
(def: .public test
Test
(<| (_.covering /._)
- (_.for [/.Sequence])
+ (_.for [/.Stream])
(let [(^open "list#[0]") (list.equivalence n.equivalence)])
(do [! random.monad]
[repeated random.nat
@@ -115,8 +115,8 @@
(list#= (list.together (list.repeated size cycle))
(/.first (n.* size (list.size cycle))
(/.cycle [cycle_start cycle_next])))))
- (_.cover [/.^sequence&]
- (let [(/.^sequence& first second third next) (..iterations ++ offset)]
+ (_.cover [/.^stream&]
+ (let [(/.^stream& first second third next) (..iterations ++ offset)]
(and (n.= offset first)
(n.= (n.+ 1 offset) second)
(n.= (n.+ 2 offset) third))))