aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/hash.lux
diff options
context:
space:
mode:
authorEduardo Julian2020-12-25 09:22:38 -0400
committerEduardo Julian2020-12-25 09:22:38 -0400
commit4ca397765805eda5ddee393901ed3a02001a960a (patch)
tree2ab184a1a4e244f3a69e86c8a7bb3ad49c22b4a3 /stdlib/source/program/aedifex/hash.lux
parentd29e091e98dabb8dfcf816899ada480ecbf7e357 (diff)
Replaced kebab-case with snake_case for naming convention.
Diffstat (limited to 'stdlib/source/program/aedifex/hash.lux')
-rw-r--r--stdlib/source/program/aedifex/hash.lux44
1 files changed, 22 insertions, 22 deletions
diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux
index 74d965f8c..2c0c6df25 100644
--- a/stdlib/source/program/aedifex/hash.lux
+++ b/stdlib/source/program/aedifex/hash.lux
@@ -69,13 +69,13 @@
[16 md5::size]
)
- (def: hex-per-byte
+ (def: hex_per_byte
2)
- (def: hex-per-chunk
- (n.* hex-per-byte i64.bytes-per-i64))
+ (def: hex_per_chunk
+ (n.* hex_per_byte i64.bytes_per_i64))
- (exception: #export (not-a-hash {size Nat} {value Text})
+ (exception: #export (not_a_hash {size Nat} {value Text})
(exception.report
["Pseudo hash" (%.text value)]
["Expected size" (%.nat size)]
@@ -88,8 +88,8 @@
["Expected size" (%.nat <size>)]
["Actual size" (%.nat (binary.size data))]))]
- [not-a-sha-1 ..sha-1::size]
- [not-a-md5 ..md5::size]
+ [not_a_sha-1 ..sha-1::size]
+ [not_a_md5 ..md5::size]
)
(template [<name> <kind> <size> <exception>]
@@ -99,29 +99,29 @@
(#try.Success (:abstraction data))
(exception.throw <exception> [data])))]
- [as-sha-1 SHA-1 ..sha-1::size ..not-a-sha-1]
- [as-md5 MD5 ..md5::size ..not-a-md5]
+ [as_sha-1 SHA-1 ..sha-1::size ..not_a_sha-1]
+ [as_md5 MD5 ..md5::size ..not_a_md5]
)
- (def: hash-size
+ (def: hash_size
(-> Text Nat)
- (|>> text.size (n./ ..hex-per-byte)))
+ (|>> text.size (n./ ..hex_per_byte)))
- (def: encoding-size
+ (def: encoding_size
(-> Nat Nat)
- (n.* ..hex-per-byte))
+ (n.* ..hex_per_byte))
(def: (decode size constructor encoded)
(All [h]
(-> Nat (-> Binary (Try (Hash h)))
(-> Text (Try (Hash h)))))
- (let [hash-size (..hash-size encoded)]
- (if (n.= size hash-size)
+ (let [hash_size (..hash_size encoded)]
+ (if (n.= size hash_size)
(loop [input encoded
chunk 0
- output (binary.create hash-size)]
- (let [index (n.* chunk i64.bytes-per-i64)]
- (case (text.split ..hex-per-chunk input)
+ output (binary.create hash_size)]
+ (let [index (n.* chunk i64.bytes_per_i64)]
+ (case (text.split ..hex_per_chunk input)
(#.Some [head tail])
(do try.monad
[head (\ n.hex decode head)
@@ -129,7 +129,7 @@
(recur tail (inc chunk) output))
#.None
- (case (..hash-size input)
+ (case (..hash_size input)
0 (constructor output)
(^template [<size> <write>]
[<size>
@@ -140,8 +140,8 @@
([1 binary.write/8]
[2 binary.write/16]
[4 binary.write/32])
- _ (exception.throw ..not-a-hash [(..encoding-size size) encoded])))))
- (exception.throw ..not-a-hash [(..encoding-size size) encoded]))))
+ _ (exception.throw ..not_a_hash [(..encoding_size size) encoded])))))
+ (exception.throw ..not_a_hash [(..encoding_size size) encoded]))))
(template [<codec> <hash> <nat> <constructor>]
[(structure: #export <codec>
@@ -150,8 +150,8 @@
(def: encode (|>> :representation ..encode))
(def: decode (..decode <nat> <constructor>)))]
- [sha-1-codec SHA-1 ..sha-1::size ..as-sha-1]
- [md5-codec MD5 ..md5::size ..as-md5]
+ [sha-1_codec SHA-1 ..sha-1::size ..as_sha-1]
+ [md5_codec MD5 ..md5::size ..as_md5]
)
(structure: #export equivalence