From 9e2f1e76f2c8df01ed7687d934c3210fcf676bd6 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 16 Jun 2022 00:48:19 -0400 Subject: De-sigil-ification: suffix : [Part 13] --- stdlib/source/program/aedifex/hash.lux | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'stdlib/source/program/aedifex/hash.lux') diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index 7a2668bc7..5d5890c3a 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -40,12 +40,12 @@ (primitive .public (Hash h) Binary - (def: .public data + (def .public data (All (_ h) (-> (Hash h) Binary)) (|>> representation)) (with_template [ ] - [(def: .public ( value) + [(def .public ( value) (-> Binary (Hash )) (|> (java/security/MessageDigest::getInstance [(ffi.as_string )]) (java/security/MessageDigest::digest [value]) @@ -55,7 +55,7 @@ [md5 ..MD5 "MD5"] ) - (def: encoded + (def encoded (Format Binary) (binary.mix (function (_ byte representation) (let [hex (at n.hex encoded byte) @@ -66,7 +66,7 @@ "")) (with_template [ ] - [(def: + [(def Nat )] @@ -74,10 +74,10 @@ [16 md5::size] ) - (def: hex_per_byte + (def hex_per_byte 2) - (def: hex_per_chunk + (def hex_per_chunk (n.* hex_per_byte i64.bytes_per_i64)) (exception: .public (not_a_hash [size Nat @@ -99,7 +99,7 @@ ) (with_template [ ] - [(def: .public ( data) + [(def .public ( data) (-> Binary (Try (Hash ))) (if (n.= (binary.size data)) {try.#Success (abstraction data)} @@ -109,15 +109,15 @@ [as_md5 MD5 ..md5::size ..not_a_md5] ) - (def: hash_size + (def hash_size (-> Text Nat) (|>> text.size (n./ ..hex_per_byte))) - (def: encoding_size + (def encoding_size (-> Nat Nat) (n.* ..hex_per_byte)) - (def: (decoded size constructor encoded) + (def (decoded size constructor encoded) (All (_ h) (-> Nat (-> Binary (Try (Hash h))) (-> Text (Try (Hash h))))) @@ -150,20 +150,20 @@ (exception.except ..not_a_hash [(..encoding_size size) encoded])))) (with_template [ ] - [(def: .public + [(def .public (Codec Text (Hash )) (implementation - (def: encoded (|>> representation ..encoded)) - (def: decoded (..decoded ))))] + (def encoded (|>> representation ..encoded)) + (def decoded (..decoded ))))] [sha-1_codec SHA-1 ..sha-1::size ..as_sha-1] [md5_codec MD5 ..md5::size ..as_md5] ) - (def: .public equivalence + (def .public equivalence (All (_ h) (Equivalence (Hash h))) (implementation - (def: (= reference subject) + (def (= reference subject) (at binary.equivalence = (representation reference) (representation subject))))) -- cgit v1.2.3