aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2022-03-30 19:23:12 -0400
committerEduardo Julian2022-03-30 19:23:12 -0400
commit4326d69ab717683449bf37bf8dd170c83455c0c0 (patch)
tree384442f7d0fb3c80543df9f6d6511d159b90b79f
parent9df5ff6abc6e95c766d1907c5a9fee00730e749a (diff)
Lined-up names of "safe" binary/array defs with names of "unsafe" ones.
-rw-r--r--.github/workflows/setup_aedifex/action.yml3
-rw-r--r--stdlib/source/library/lux/control/concurrency/thread.lux2
-rw-r--r--stdlib/source/library/lux/control/parser/binary.lux8
-rw-r--r--stdlib/source/library/lux/control/thread.lux4
-rw-r--r--stdlib/source/library/lux/data/binary.lux22
-rw-r--r--stdlib/source/library/lux/data/collection/array.lux15
-rw-r--r--stdlib/source/library/lux/data/collection/bits.lux10
-rw-r--r--stdlib/source/library/lux/data/format/binary.lux42
-rw-r--r--stdlib/source/library/lux/data/format/tar.lux2
-rw-r--r--stdlib/source/library/lux/debug.lux4
-rw-r--r--stdlib/source/library/lux/math/number/rev.lux4
-rw-r--r--stdlib/source/library/lux/target/jvm/bytecode/instruction.lux88
-rw-r--r--stdlib/source/test/lux/data/binary.lux54
-rw-r--r--stdlib/source/test/lux/data/collection/array.lux56
-rw-r--r--stdlib/source/unsafe/lux/data/binary.lux58
15 files changed, 188 insertions, 184 deletions
diff --git a/.github/workflows/setup_aedifex/action.yml b/.github/workflows/setup_aedifex/action.yml
index 5afa83812..2b81a4fbc 100644
--- a/.github/workflows/setup_aedifex/action.yml
+++ b/.github/workflows/setup_aedifex/action.yml
@@ -4,6 +4,9 @@ runs:
steps:
- uses: actions/checkout@v2
- run: wget https://github.com/LuxLang/lux/releases/download/0.6.5/aedifex_do_not_touch_3.jar && mv aedifex_do_not_touch_3.jar aedifex.jar
+ shell: bash
- run: mv ./shell/lux.sh ./lux.sh
+ shell: bash
- run: cd ./stdlib/ && ../lux.sh clean && cd ..
+ shell: bash
diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux
index 3ba009a7c..db9c06846 100644
--- a/stdlib/source/library/lux/control/concurrency/thread.lux
+++ b/stdlib/source/library/lux/control/concurrency/thread.lux
@@ -170,7 +170,7 @@
(if started?
(in [])
(do !
- [_ (atom.write! true ..started?)]
+ [_ (atom.has! true ..started?)]
(loop (again [_ []])
(do !
[threads (atom.read! ..runner)]
diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux
index 015961926..0fc0350d2 100644
--- a/stdlib/source/library/lux/control/parser/binary.lux
+++ b/stdlib/source/library/lux/control/parser/binary.lux
@@ -85,10 +85,10 @@
{try.#Failure error}
{try.#Failure error})))]
- [bits/8 ..size/8 /.read/8!]
- [bits/16 ..size/16 /.read/16!]
- [bits/32 ..size/32 /.read/32!]
- [bits/64 ..size/64 /.read/64!]
+ [bits/8 ..size/8 /.bytes/1]
+ [bits/16 ..size/16 /.bytes/2]
+ [bits/32 ..size/32 /.bytes/4]
+ [bits/64 ..size/64 /.bytes/8]
)
(template [<name> <type>]
diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux
index 95c7ddc69..4b5fdfc35 100644
--- a/stdlib/source/library/lux/control/thread.lux
+++ b/stdlib/source/library/lux/control/thread.lux
@@ -24,7 +24,7 @@
(All (_ a) (-> a (All (_ !) (Thread ! (Box ! a)))))
(function (_ !)
(|> (array.empty 1)
- (array.write! 0 init)
+ (array.has! 0 init)
abstraction)))
(def: .public (read! box)
@@ -51,7 +51,7 @@
(def: .public (write! value box)
(All (_ a) (-> a (All (_ !) (-> (Box ! a) (Thread ! Any)))))
(function (_ !)
- (|> box representation (array.write! 0 value) abstraction)))
+ (|> box representation (array.has! 0 value) abstraction)))
)
(def: .public (result thread)
diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux
index 6cea2f879..c65ea01a7 100644
--- a/stdlib/source/library/lux/data/binary.lux
+++ b/stdlib/source/library/lux/data/binary.lux
@@ -27,9 +27,9 @@
(-> Binary Nat)
(|>> /.size))
-(def: .public (empty size)
+(def: .public empty
(-> Nat Binary)
- (/.empty size))
+ (|>> /.empty))
(def: .public (aggregate $ init it)
(All (_ a) (-> (-> I64 a a) a Binary a))
@@ -53,10 +53,10 @@
{try.#Success (<unsafe> index it)}
(exception.except ..index_out_of_bounds [(/.size it) index])))]
- [read/8! /.bytes/1 (|>)]
- [read/16! /.bytes/2 (n.+ 1)]
- [read/32! /.bytes/4 (n.+ 3)]
- [read/64! /.bytes/8 (n.+ 7)]
+ [bytes/1 /.bytes/1 (|>)]
+ [bytes/2 /.bytes/2 (n.+ 1)]
+ [bytes/4 /.bytes/4 (n.+ 3)]
+ [bytes/8 /.bytes/8 (n.+ 7)]
)
(template [<safe> <unsafe> <shift>]
@@ -66,10 +66,10 @@
{try.#Success (<unsafe> index value it)}
(exception.except ..index_out_of_bounds [(/.size it) index])))]
- [write/8! /.with/1! (|>)]
- [write/16! /.with/2! (n.+ 1)]
- [write/32! /.with/4! (n.+ 3)]
- [write/64! /.with/8! (n.+ 7)]
+ [has/1! /.has/1! (|>)]
+ [has/2! /.has/2! (n.+ 1)]
+ [has/4! /.has/4! (n.+ 3)]
+ [has/8! /.has/8! (n.+ 7)]
)
(implementation: .public equivalence
@@ -86,7 +86,7 @@
"Source input space" (%.nat source_input)
"Target output space" (%.nat target_output)))
-(def: .public (copy bytes source_offset source target_offset target)
+(def: .public (copy! bytes source_offset source target_offset target)
(-> Nat Nat Binary Nat Binary (Try Binary))
(let [source_input (n.- source_offset (/.size source))
target_output (n.- target_offset (/.size target))]
diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux
index f3a0efe41..4a931cfae 100644
--- a/stdlib/source/library/lux/data/collection/array.lux
+++ b/stdlib/source/library/lux/data/collection/array.lux
@@ -13,6 +13,7 @@
["!" \\unsafe])
(def: .public type_name
+ Text
!.type)
(type: .public Array
@@ -26,19 +27,19 @@
(All (_ a) (-> (Array a) Nat))
(|>> !.size))
-(def: .public (read! index array)
+(def: .public (item index array)
(All (_ a)
(-> Nat (Array a) (Maybe a)))
(if (!.lacks? index array)
{.#None}
{.#Some (!.item index array)}))
-(def: .public (write! index value array)
+(def: .public (has! index value array)
(All (_ a)
(-> Nat a (Array a) (Array a)))
(!.has! index value array))
-(def: .public (delete! index array)
+(def: .public (lacks! index array)
(All (_ a)
(-> Nat (Array a) (Array a)))
(!.lacks! index array))
@@ -48,12 +49,12 @@
(-> Nat (Array a) Bit))
(!.lacks? index array))
-(def: .public (contains? index array)
+(def: .public (has? index array)
(All (_ a)
(-> Nat (Array a) Bit))
(!.has? index array))
-(def: .public (update! index $ array)
+(def: .public (revised! index $ array)
(All (_ a)
(-> Nat (-> a a) (Array a) (Array a)))
(!.revised! index $ array))
@@ -77,7 +78,7 @@
(All (_ a) (-> (Array a) Nat))
(|>> !.vacancy))
-(def: .public (filter! ? it)
+(def: .public (only! ? it)
(All (_ a)
(-> (Predicate a) (Array a) (Array a)))
(!.only! ? it))
@@ -87,7 +88,7 @@
(-> (Predicate a) (Array a) (Maybe a)))
(!.example ? it))
-(def: .public (example+ ? it)
+(def: .public (example' ? it)
(All (_ a)
(-> (-> Nat a Bit) (Array a) (Maybe [Nat a])))
(!.example' ? it))
diff --git a/stdlib/source/library/lux/data/collection/bits.lux b/stdlib/source/library/lux/data/collection/bits.lux
index c6f692f52..45d3e154e 100644
--- a/stdlib/source/library/lux/data/collection/bits.lux
+++ b/stdlib/source/library/lux/data/collection/bits.lux
@@ -50,14 +50,14 @@
(-> Nat Bits Bit)
(let [[chunk_index bit_index] (n./% chunk_size index)]
(.and (n.< (array.size bits) chunk_index)
- (|> (array.read! chunk_index bits)
+ (|> (array.item chunk_index bits)
(maybe.else empty_chunk)
(i64.one? bit_index)))))
(def: (chunk idx bits)
(-> Nat Bits Chunk)
(if (n.< (array.size bits) idx)
- (|> bits (array.read! idx) (maybe.else empty_chunk))
+ (|> bits (array.item idx) (maybe.else empty_chunk))
empty_chunk))
(template [<name> <op>]
@@ -85,7 +85,7 @@
(|> (if (same? ..empty output)
(is Bits (array.empty size|output))
output)
- (array.write! idx|output (.i64 chunk))
+ (array.has! idx|output (.i64 chunk))
(again (-- size|output))))
output)))))]
@@ -126,7 +126,7 @@
(|> (if (same? ..empty output)
(is Bits (array.empty size|output))
output)
- (array.write! idx (.i64 chunk))
+ (array.has! idx (.i64 chunk))
(again (-- size|output)))
output))))))
@@ -153,7 +153,7 @@
(|> (if (same? ..empty output)
(is Bits (array.empty size|output))
output)
- (array.write! idx (.i64 chunk))
+ (array.has! idx (.i64 chunk))
(again (-- size|output))))
output)))))]
diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux
index cc85465f6..1d99204b6 100644
--- a/stdlib/source/library/lux/data/format/binary.lux
+++ b/stdlib/source/library/lux/data/format/binary.lux
@@ -76,10 +76,10 @@
(<write> offset value)
try.trusted)])]))]
- [bits/8 /.size/8 binary.write/8!]
- [bits/16 /.size/16 binary.write/16!]
- [bits/32 /.size/32 binary.write/32!]
- [bits/64 /.size/64 binary.write/64!]
+ [bits/8 /.size/8 binary.has/1!]
+ [bits/16 /.size/16 binary.has/2!]
+ [bits/32 /.size/32 binary.has/4!]
+ [bits/64 /.size/64 binary.has/8!]
)
(def: .public (or left right)
@@ -92,7 +92,7 @@
[(.++ caseS)
(function (_ [offset binary])
(|> binary
- (binary.write/8! offset <number>)
+ (binary.has/1! offset <number>)
try.trusted
[(.++ offset)]
caseT))])])
@@ -137,11 +137,11 @@
(function (_ [offset binary])
[(n.+ size offset)
(try.trusted
- (binary.copy (n.min size (binary.size value))
- 0
- value
- offset
- binary))])]))
+ (binary.copy! (n.min size (binary.size value))
+ 0
+ value
+ offset
+ binary))])]))
(template [<name> <bits> <size> <write>]
[(def: .public <name>
@@ -156,12 +156,12 @@
(try.trusted
(do try.monad
[_ (<write> offset size binary)]
- (binary.copy size 0 value (n.+ <size> offset) binary)))])]))))]
+ (binary.copy! size 0 value (n.+ <size> offset) binary)))])]))))]
- [binary/8 ..bits/8 /.size/8 binary.write/8!]
- [binary/16 ..bits/16 /.size/16 binary.write/16!]
- [binary/32 ..bits/32 /.size/32 binary.write/32!]
- [binary/64 ..bits/64 /.size/64 binary.write/64!]
+ [binary/8 ..bits/8 /.size/8 binary.has/1!]
+ [binary/16 ..bits/16 /.size/16 binary.has/2!]
+ [binary/32 ..bits/32 /.size/32 binary.has/4!]
+ [binary/64 ..bits/64 /.size/64 binary.has/8!]
)
(template [<name> <binary>]
@@ -201,10 +201,10 @@
[_ (<write> offset capped_count binary)]
(in (mutation [(n.+ <size> offset) binary])))))])))]
- [sequence/8 /.size/8 binary.write/8!]
- [sequence/16 /.size/16 binary.write/16!]
- [sequence/32 /.size/32 binary.write/32!]
- [sequence/64 /.size/64 binary.write/64!]
+ [sequence/8 /.size/8 binary.has/1!]
+ [sequence/16 /.size/16 binary.has/2!]
+ [sequence/32 /.size/32 binary.has/4!]
+ [sequence/64 /.size/64 binary.has/8!]
)
(def: .public maybe
@@ -240,7 +240,7 @@
[(.++ caseS)
(function (_ [offset binary])
(|> binary
- (binary.write/8! offset <number>)
+ (binary.has/1! offset <number>)
try.trusted
[(.++ offset)]
caseT))])])
@@ -275,7 +275,7 @@
[(.++ caseS)
(function (_ [offset binary])
(|> binary
- (binary.write/8! offset <number>)
+ (binary.has/1! offset <number>)
try.trusted
[(.++ offset)]
caseT))])])
diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux
index 264acaf46..2f0a2b38a 100644
--- a/stdlib/source/library/lux/data/format/tar.lux
+++ b/stdlib/source/library/lux/data/format/tar.lux
@@ -237,7 +237,7 @@
(case end
0 {try.#Success (# utf8.codec encoded "")}
_ (do try.monad
- [last_char (binary.read/8! end string)]
+ [last_char (binary.bytes/1 end string)]
(`` (case (.nat last_char)
(pattern (char (~~ (static ..null))))
(again (-- end))
diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux
index 14399ccad..d5ed1cff8 100644
--- a/stdlib/source/library/lux/debug.lux
+++ b/stdlib/source/library/lux/debug.lux
@@ -161,11 +161,11 @@
(case (ffi.as [java/lang/Object] object)
{.#Some value}
(let [value (as (array.Array java/lang/Object) value)]
- (case (array.read! 0 value)
+ (case (array.item 0 value)
(^.multi {.#Some tag}
[(ffi.as java/lang/Integer tag)
{.#Some tag}]
- [[(array.read! 1 value) (array.read! 2 value)]
+ [[(array.item 1 value) (array.item 2 value)]
[last? {.#Some choice}]])
(let [last? (case last?
{.#Some _} #1
diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux
index 6fed06ede..cf07f2039 100644
--- a/stdlib/source/library/lux/math/number/rev.lux
+++ b/stdlib/source/library/lux/math/number/rev.lux
@@ -286,12 +286,12 @@
(def: (digit idx digits)
(-> Nat Digits Nat)
(|> digits
- (array.read! idx)
+ (array.item idx)
(maybe.else 0)))
(def: digits#put!
(-> Nat Nat Digits Digits)
- array.write!)
+ array.has!)
(def: (digits#times_5! idx output)
(-> Nat Digits Digits)
diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux
index bbfdefdd4..d6717d8a9 100644
--- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux
+++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux
@@ -79,7 +79,7 @@
(function (_ [offset binary])
[(n.+ (///unsigned.value ..opcode_size)
offset)
- (binary.with/1! offset opcode binary)]))
+ (binary.has/1! offset opcode binary)]))
(def: nullary
[Estimator (-> Opcode Instruction)]
@@ -108,7 +108,7 @@
(function (_ [offset binary])
[(n.+ (///unsigned.value <shift>) offset)
(|> binary
- (binary.with/1! offset opcode)
+ (binary.has/1! offset opcode)
(<writer> (n.+ (///unsigned.value ..opcode_size) offset)
(<unwrap> input0)))]))
@@ -119,10 +119,10 @@
[(n.+ (///unsigned.value <shift>) size)
(|>> mutation ((<private> opcode input0)))])]))]
- [..size/1 unary/1 U1 binary.with/1! ///unsigned.value]
- [..size/2 unary/2 U2 binary.with/2! ///unsigned.value]
- [..size/2 jump/2 Jump binary.with/2! ///signed.value]
- [..size/4 jump/4 Big_Jump binary.with/4! ///signed.value]
+ [..size/1 unary/1 U1 binary.has/1! ///unsigned.value]
+ [..size/2 unary/2 U2 binary.has/2! ///unsigned.value]
+ [..size/2 jump/2 Jump binary.has/2! ///signed.value]
+ [..size/4 jump/4 Big_Jump binary.has/4! ///signed.value]
)
(template [<shift> <name> <inputT> <writer>]
@@ -132,7 +132,7 @@
(function (_ [offset binary])
[(n.+ (///unsigned.value <shift>) offset)
(|> binary
- (binary.with/1! offset opcode)
+ (binary.has/1! offset opcode)
(<writer> (n.+ (///unsigned.value ..opcode_size) offset)
(///signed.value input0)))]))
@@ -143,8 +143,8 @@
[(n.+ (///unsigned.value <shift>) size)
(|>> mutation ((<private> opcode input0)))])]))]
- [..size/1 unary/1' S1 binary.with/1!]
- [..size/2 unary/2' S2 binary.with/2!]
+ [..size/1 unary/1' S1 binary.has/1!]
+ [..size/2 unary/2' S2 binary.has/2!]
)
(def: size/11
@@ -158,11 +158,11 @@
(function (_ [offset binary])
[(n.+ (///unsigned.value ..size/11) offset)
(|> binary
- (binary.with/1! offset opcode)
- (binary.with/1! (n.+ (///unsigned.value ..opcode_size) offset)
- (///unsigned.value input0))
- (binary.with/1! (n.+ (///unsigned.value ..size/1) offset)
- (///unsigned.value input1)))]))
+ (binary.has/1! offset opcode)
+ (binary.has/1! (n.+ (///unsigned.value ..opcode_size) offset)
+ (///unsigned.value input0))
+ (binary.has/1! (n.+ (///unsigned.value ..size/1) offset)
+ (///unsigned.value input1)))]))
(def: binary/11
[Estimator (-> Opcode U1 U1 Instruction)]
@@ -182,11 +182,11 @@
(function (_ [offset binary])
[(n.+ (///unsigned.value ..size/21) offset)
(|> binary
- (binary.with/1! offset opcode)
- (binary.with/2! (n.+ (///unsigned.value ..opcode_size) offset)
- (///unsigned.value input0))
- (binary.with/1! (n.+ (///unsigned.value ..size/2) offset)
- (///unsigned.value input1)))]))
+ (binary.has/1! offset opcode)
+ (binary.has/2! (n.+ (///unsigned.value ..opcode_size) offset)
+ (///unsigned.value input0))
+ (binary.has/1! (n.+ (///unsigned.value ..size/2) offset)
+ (///unsigned.value input1)))]))
(def: binary/21
[Estimator (-> Opcode U2 U1 Instruction)]
@@ -207,13 +207,13 @@
(function (_ [offset binary])
[(n.+ (///unsigned.value ..size/211) offset)
(|> binary
- (binary.with/1! offset opcode)
- (binary.with/2! (n.+ (///unsigned.value ..opcode_size) offset)
- (///unsigned.value input0))
- (binary.with/1! (n.+ (///unsigned.value ..size/2) offset)
- (///unsigned.value input1))
- (binary.with/1! (n.+ (///unsigned.value ..size/21) offset)
- (///unsigned.value input2)))]))
+ (binary.has/1! offset opcode)
+ (binary.has/2! (n.+ (///unsigned.value ..opcode_size) offset)
+ (///unsigned.value input0))
+ (binary.has/1! (n.+ (///unsigned.value ..size/2) offset)
+ (///unsigned.value input1))
+ (binary.has/1! (n.+ (///unsigned.value ..size/21) offset)
+ (///unsigned.value input2)))]))
(def: trinary/211
[Estimator (-> Opcode U2 U1 U1 Instruction)]
@@ -606,21 +606,21 @@
(do [! try.monad]
[amount_of_afterwards (|> amount_of_afterwards .int ///signed.s4)
maximum (///signed.+/4 minimum amount_of_afterwards)]
- (in (let [_ (binary.with/1! offset (hex "AA") binary)
+ (in (let [_ (binary.has/1! offset (hex "AA") binary)
offset (n.+ (///unsigned.value ..opcode_size) offset)
_ (case padding
3 (|> binary
- (binary.with/1! offset 0)
- (binary.with/2! (++ offset) 0))
- 2 (binary.with/2! offset 0 binary)
- 1 (binary.with/1! offset 0 binary)
+ (binary.has/1! offset 0)
+ (binary.has/2! (++ offset) 0))
+ 2 (binary.has/2! offset 0 binary)
+ 1 (binary.has/1! offset 0 binary)
_ binary)
offset (n.+ padding offset)
- _ (binary.with/4! offset (///signed.value default) binary)
+ _ (binary.has/4! offset (///signed.value default) binary)
offset (n.+ (///unsigned.value ..big_jump_size) offset)
- _ (binary.with/4! offset (///signed.value minimum) binary)
+ _ (binary.has/4! offset (///signed.value minimum) binary)
offset (n.+ (///unsigned.value ..integer_size) offset)
- _ (binary.with/4! offset (///signed.value maximum) binary)]
+ _ (binary.has/4! offset (///signed.value maximum) binary)]
(loop (again [offset (n.+ (///unsigned.value ..integer_size) offset)
afterwards (is (List Big_Jump)
{.#Item at_minimum afterwards})])
@@ -630,7 +630,7 @@
{.#Item head tail}
(exec
- (binary.with/4! offset (///signed.value head) binary)
+ (binary.has/4! offset (///signed.value head) binary)
(again (n.+ (///unsigned.value ..big_jump_size) offset)
tail))))))))]))]
[(n.+ tableswitch_size
@@ -666,19 +666,19 @@
lookupswitch_mutation (is Mutation
(function (_ [offset binary])
[(n.+ lookupswitch_size offset)
- (let [_ (binary.with/1! offset (hex "AB") binary)
+ (let [_ (binary.has/1! offset (hex "AB") binary)
offset (n.+ (///unsigned.value ..opcode_size) offset)
_ (case padding
3 (|> binary
- (binary.with/1! offset 0)
- (binary.with/2! (++ offset) 0))
- 2 (binary.with/2! offset 0 binary)
- 1 (binary.with/1! offset 0 binary)
+ (binary.has/1! offset 0)
+ (binary.has/2! (++ offset) 0))
+ 2 (binary.has/2! offset 0 binary)
+ 1 (binary.has/1! offset 0 binary)
_ binary)
offset (n.+ padding offset)
- _ (binary.with/4! offset (///signed.value default) binary)
+ _ (binary.has/4! offset (///signed.value default) binary)
offset (n.+ (///unsigned.value ..big_jump_size) offset)
- _ (binary.with/4! offset amount_of_cases binary)]
+ _ (binary.has/4! offset amount_of_cases binary)]
(loop (again [offset (n.+ (///unsigned.value ..integer_size) offset)
cases cases])
(case cases
@@ -687,8 +687,8 @@
{.#Item [value jump] tail}
(exec
- (binary.with/4! offset (///signed.value value) binary)
- (binary.with/4! (n.+ (///unsigned.value ..integer_size) offset) (///signed.value jump) binary)
+ (binary.has/4! offset (///signed.value value) binary)
+ (binary.has/4! (n.+ (///unsigned.value ..integer_size) offset) (///signed.value jump) binary)
(again (n.+ case_size offset)
tail)))))]))]
[(n.+ lookupswitch_size
diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux
index 2098203de..25877dfd7 100644
--- a/stdlib/source/test/lux/data/binary.lux
+++ b/stdlib/source/test/lux/data/binary.lux
@@ -42,7 +42,7 @@
(if (n.< size idx)
(do random.monad
[byte random.nat]
- (exec (try.trusted (/.write/8! idx byte output))
+ (exec (try.trusted (/.has/1! idx byte output))
(again (++ idx))))
(# random.monad in output)))))
@@ -100,8 +100,8 @@
(!.= (!.empty size) (!.empty size)))
(_.cover [!.size]
(|> (!.empty size) !.size (n.= size)))
- (~~ (template [<power> <bytes/?> <with/?>]
- [(_.cover [<bytes/?> <with/?>]
+ (~~ (template [<power> <bytes/?> <has/?>]
+ [(_.cover [<bytes/?> <has/?>]
(let [bytes (i64.left_shifted <power> 1)
binary (!.empty bytes)
cap (case bytes
@@ -110,15 +110,15 @@
capped_value (i64.and cap value)
pre (<bytes/?> 0 binary)
- _ (<with/?> 0 value binary)
+ _ (<has/?> 0 value binary)
post (<bytes/?> 0 binary)]
(and (n.= 0 pre)
(n.= capped_value post))))]
- [0 !.bytes/1 !.with/1!]
- [1 !.bytes/2 !.with/2!]
- [2 !.bytes/4 !.with/4!]
- [3 !.bytes/8 !.with/8!]))
+ [0 !.bytes/1 !.has/1!]
+ [1 !.bytes/2 !.has/2!]
+ [2 !.bytes/4 !.has/4!]
+ [3 !.bytes/8 !.has/8!]))
(_.cover [!.slice]
(let [random_slice (!.slice offset length sample)
idxs (is (List Nat)
@@ -172,14 +172,14 @@
(|> (/.empty size) /.size (n.= size)))
(_.for [/.index_out_of_bounds]
($_ _.and
- (_.cover [/.read/8! /.write/8!]
- (..binary_io 0 /.read/8! /.write/8! value))
- (_.cover [/.read/16! /.write/16!]
- (..binary_io 1 /.read/16! /.write/16! value))
- (_.cover [/.read/32! /.write/32!]
- (..binary_io 2 /.read/32! /.write/32! value))
- (_.cover [/.read/64! /.write/64!]
- (..binary_io 3 /.read/64! /.write/64! value))))
+ (_.cover [/.bytes/1 /.has/1!]
+ (..binary_io 0 /.bytes/1 /.has/1! value))
+ (_.cover [/.bytes/2 /.has/2!]
+ (..binary_io 1 /.bytes/2 /.has/2! value))
+ (_.cover [/.bytes/4 /.has/4!]
+ (..binary_io 2 /.bytes/4 /.has/4! value))
+ (_.cover [/.bytes/8 /.has/8!]
+ (..binary_io 3 /.bytes/8 /.has/8! value))))
(_.cover [/.slice]
(let [random_slice (try.trusted (/.slice offset length sample))
idxs (is (List Nat)
@@ -187,7 +187,7 @@
0 (list)
_ (enum.range n.enum 0 (-- length))))
reader (function (_ binary idx)
- (/.read/8! idx binary))]
+ (/.bytes/1 idx binary))]
(and (n.= length (/.size random_slice))
(case [(monad.each try.monad (|>> (n.+ offset) (reader sample)) idxs)
(monad.each try.monad (reader random_slice) idxs)]
@@ -213,8 +213,8 @@
{.#Item head tail}
(n.= (list.mix n.+ 0 tail)
(/.aggregate n.+ 0 (/.after 1 sample))))))
- (_.cover [/.copy]
- (and (case (/.copy size 0 sample 0 (/.empty size))
+ (_.cover [/.copy!]
+ (and (case (/.copy! size 0 sample 0 (/.empty size))
{try.#Success output}
(and (not (same? sample output))
(# /.equivalence = sample output))
@@ -223,21 +223,21 @@
false)
(succeed
(do try.monad
- [sample/0 (/.read/8! 0 sample)
- copy (/.copy 1 0 sample 0 (/.empty 2))
- copy/0 (/.read/8! 0 copy)
- copy/1 (/.read/8! 1 copy)]
+ [sample/0 (/.bytes/1 0 sample)
+ copy (/.copy! 1 0 sample 0 (/.empty 2))
+ copy/0 (/.bytes/1 0 copy)
+ copy/1 (/.bytes/1 1 copy)]
(in (and (n.= sample/0 copy/0)
(n.= 0 copy/1)))))))
(_.cover [/.cannot_copy]
(and (not (throws? /.cannot_copy
- (/.copy size 0 sample 0 (/.empty size))))
+ (/.copy! size 0 sample 0 (/.empty size))))
(throws? /.cannot_copy
- (/.copy (n.+ offset size) 0 sample 0 (/.empty size)))
+ (/.copy! (n.+ offset size) 0 sample 0 (/.empty size)))
(throws? /.cannot_copy
- (/.copy size offset sample 0 (/.empty size)))
+ (/.copy! size offset sample 0 (/.empty size)))
(throws? /.cannot_copy
- (/.copy size 0 sample offset (/.empty size)))))
+ (/.copy! size 0 sample offset (/.empty size)))))
..test|unsafe
))))
diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux
index 2d413f633..1008f2422 100644
--- a/stdlib/source/test/lux/data/collection/array.lux
+++ b/stdlib/source/test/lux/data/collection/array.lux
@@ -71,7 +71,7 @@
(_.cover [/.one]
(case [(|> evens
(/#each (# n.decimal encoded))
- (/.read! 0))
+ (/.item 0))
(/.one choose evens)]
[{.#Some expected} {.#Some actual}]
(text#= expected actual)
@@ -85,13 +85,13 @@
(# (maybe.equivalence n.equivalence) =
(/.example n.even? the_array)
(list.example n.even? (/.list {.#None} the_array))))
- (_.cover [/.example+]
+ (_.cover [/.example']
(case [(/.example n.even? the_array)
- (/.example+ (function (_ idx member)
+ (/.example' (function (_ idx member)
(n.even? member))
the_array)]
[{.#Some expected} {.#Some [idx actual]}]
- (case (/.read! idx the_array)
+ (case (/.item idx the_array)
{.#Some again}
(and (n.= expected actual)
(n.= actual again))
@@ -332,23 +332,23 @@
_
false))
- (_.cover [/.read! /.write!]
+ (_.cover [/.item /.has!]
(let [the_array (|> (/.empty 2)
(is (Array Nat))
- (/.write! 0 expected))]
- (case [(/.read! 0 the_array)
- (/.read! 1 the_array)]
+ (/.has! 0 expected))]
+ (case [(/.item 0 the_array)
+ (/.item 1 the_array)]
[{.#Some actual} {.#None}]
(n.= expected actual)
_
false)))
- (_.cover [/.delete!]
+ (_.cover [/.lacks!]
(let [the_array (|> (/.empty 1)
(is (Array Nat))
- (/.write! 0 expected))]
- (case [(/.read! 0 the_array)
- (/.read! 0 (/.delete! 0 the_array))]
+ (/.has! 0 expected))]
+ (case [(/.item 0 the_array)
+ (/.item 0 (/.lacks! 0 the_array))]
[{.#Some actual} {.#None}]
(n.= expected actual)
@@ -357,21 +357,21 @@
(_.cover [/.lacks?]
(let [the_array (|> (/.empty 2)
(is (Array Nat))
- (/.write! 0 expected))]
+ (/.has! 0 expected))]
(and (not (/.lacks? 0 the_array))
(/.lacks? 1 the_array))))
- (_.cover [/.contains?]
+ (_.cover [/.has?]
(let [the_array (|> (/.empty 2)
(is (Array Nat))
- (/.write! 0 expected))]
- (and (/.contains? 0 the_array)
- (not (/.contains? 1 the_array)))))
- (_.cover [/.update!]
+ (/.has! 0 expected))]
+ (and (/.has? 0 the_array)
+ (not (/.has? 1 the_array)))))
+ (_.cover [/.revised!]
(let [the_array (|> (/.empty 1)
(is (Array Nat))
- (/.write! 0 base)
- (/.update! 0 (n.+ shift)))]
- (case (/.read! 0 the_array)
+ (/.has! 0 base)
+ (/.revised! 0 (n.+ shift)))]
+ (case (/.item 0 the_array)
{.#Some actual}
(n.= expected actual)
@@ -380,11 +380,11 @@
(_.cover [/.upsert!]
(let [the_array (|> (/.empty 2)
(is (Array Nat))
- (/.write! 0 base)
+ (/.has! 0 base)
(/.upsert! 0 dummy (n.+ shift))
(/.upsert! 1 base (n.+ shift)))]
- (case [(/.read! 0 the_array)
- (/.read! 1 the_array)]
+ (case [(/.item 0 the_array)
+ (/.item 1 the_array)]
[{.#Some actual/0} {.#Some actual/1}]
(and (n.= expected actual/0)
(n.= expected actual/1))
@@ -398,7 +398,7 @@
(/.empty size))
idx 0])
(if (n.< occupancy idx)
- (again (/.write! idx expected output)
+ (again (/.has! idx expected output)
(++ idx))
output))]
(and (n.= occupancy (/.occupancy the_array))
@@ -418,7 +418,7 @@
(|> the_array (/.list {.#None}) /.of_list
(# (/.equivalence n.equivalence) = the_array))
(exec
- (/.filter! n.even? the_array)
+ (/.only! n.even? the_array)
(list.every? (function (_ value)
(or (n.even? value)
(same? default value)))
@@ -439,8 +439,8 @@
(let [the_array (/.clone the_array)
evens (|> the_array (/.list {.#None}) (list.only n.even?))
odds (|> the_array (/.list {.#None}) (list.only n.odd?))]
- (_.cover [/.filter!]
- (exec (/.filter! n.even? the_array)
+ (_.cover [/.only!]
+ (exec (/.only! n.even? the_array)
(and (n.= (list.size evens) (/.occupancy the_array))
(n.= (list.size odds) (/.vacancy the_array))
(|> the_array (/.list {.#None}) (# (list.equivalence n.equivalence) = evens))))))
diff --git a/stdlib/source/unsafe/lux/data/binary.lux b/stdlib/source/unsafe/lux/data/binary.lux
index bc99f1f55..33d217c40 100644
--- a/stdlib/source/unsafe/lux/data/binary.lux
+++ b/stdlib/source/unsafe/lux/data/binary.lux
@@ -198,7 +198,7 @@
<jvm_value> <jvm_value>
<jvm_value> (ffi.long_to_byte <jvm_value>)
<jvm> (ffi.write! <index> <jvm_value> <it>)]
- (`` (template: .public (with/1! index value it)
+ (`` (template: .public (has/1! index value it)
[(.is ..Binary
(.for (~~ (.static @.old)) <jvm>
(~~ (.static @.jvm)) <jvm>
@@ -230,47 +230,47 @@
... Default
(array.has! <index> (.|> <value> .int ("lux i64 and" (.int <byte>))) <it>)))])))
-(template: .public (with/2! index' value' it)
+(template: .public (has/2! index' value' it)
[(.let [index (.is .Nat index')
value (.is (.I64 .Any) value')]
(.|> it
- (..with/1! index ("lux i64 right-shift" 8 value))
- (..with/1! ("lux i64 +" 1 index) value)))])
+ (..has/1! index ("lux i64 right-shift" 8 value))
+ (..has/1! ("lux i64 +" 1 index) value)))])
-(template: .public (with/4! index' value' it)
+(template: .public (has/4! index' value' it)
[(.let [index (.is .Nat index')
value (.is (.I64 .Any) value')]
(.|> it
- (..with/1! index ("lux i64 right-shift" 24 value))
- (..with/1! ("lux i64 +" 1 index) ("lux i64 right-shift" 16 value))
- (..with/1! ("lux i64 +" 2 index) ("lux i64 right-shift" 8 value))
- (..with/1! ("lux i64 +" 3 index) value)))])
+ (..has/1! index ("lux i64 right-shift" 24 value))
+ (..has/1! ("lux i64 +" 1 index) ("lux i64 right-shift" 16 value))
+ (..has/1! ("lux i64 +" 2 index) ("lux i64 right-shift" 8 value))
+ (..has/1! ("lux i64 +" 3 index) value)))])
-(`` (template: .public (with/8! index' value' it)
+(`` (template: .public (has/8! index' value' it)
[(.let [index (.is .Nat index')
value (.is (.I64 .Any) value')]
(.for (~~ (.static @.scheme)) (.let [write_high (.is (.-> ..Binary ..Binary)
- (.|>> (..with/1! index ("lux i64 right-shift" 56 value))
- (..with/1! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value))
- (..with/1! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value))
- (..with/1! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value))))
+ (.|>> (..has/1! index ("lux i64 right-shift" 56 value))
+ (..has/1! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value))
+ (..has/1! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value))
+ (..has/1! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value))))
write_low (.is (.-> ..Binary ..Binary)
- (.|>> (..with/1! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value))
- (..with/1! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value))
- (..with/1! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value))
- (..with/1! ("lux i64 +" 7 index) value)))]
+ (.|>> (..has/1! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value))
+ (..has/1! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value))
+ (..has/1! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value))
+ (..has/1! ("lux i64 +" 7 index) value)))]
(.|> it
write_high
write_low))
(.|> it
- (..with/1! index ("lux i64 right-shift" 56 value))
- (..with/1! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value))
- (..with/1! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value))
- (..with/1! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value))
- (..with/1! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value))
- (..with/1! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value))
- (..with/1! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value))
- (..with/1! ("lux i64 +" 7 index) value))))]))
+ (..has/1! index ("lux i64 right-shift" 56 value))
+ (..has/1! ("lux i64 +" 1 index) ("lux i64 right-shift" 48 value))
+ (..has/1! ("lux i64 +" 2 index) ("lux i64 right-shift" 40 value))
+ (..has/1! ("lux i64 +" 3 index) ("lux i64 right-shift" 32 value))
+ (..has/1! ("lux i64 +" 4 index) ("lux i64 right-shift" 24 value))
+ (..has/1! ("lux i64 +" 5 index) ("lux i64 right-shift" 16 value))
+ (..has/1! ("lux i64 +" 6 index) ("lux i64 right-shift" 8 value))
+ (..has/1! ("lux i64 +" 7 index) value))))]))
(with_expansions [<reference> (.is ..Binary reference')
<sample> (.is ..Binary sample')
@@ -307,9 +307,9 @@
(.loop (again [index 0])
(.if ("lux i64 <" (.int bytes) (.int index))
(.exec
- (..with/1! ("lux i64 +" target_offset index)
- (..bytes/1 ("lux i64 +" source_offset index) source)
- target)
+ (..has/1! ("lux i64 +" target_offset index)
+ (..bytes/1 ("lux i64 +" source_offset index) source)
+ target)
(again ("lux i64 +" 1 index)))
target))))))