From 7768aec2da52945d63232a1014b0f177de881a82 Mon Sep 17 00:00:00 2001 From: Mattthew Heath Date: Tue, 10 Sep 2024 21:41:35 +0100 Subject: [PATCH] Attempt to fix formatting --- crates/compiler/builtins/roc/Crypt.roc | 23 ++++++----------------- crates/compiler/gen_wasm/src/low_level.rs | 4 +++- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/crates/compiler/builtins/roc/Crypt.roc b/crates/compiler/builtins/roc/Crypt.roc index f429197166..679fb418c5 100644 --- a/crates/compiler/builtins/roc/Crypt.roc +++ b/crates/compiler/builtins/roc/Crypt.roc @@ -12,15 +12,9 @@ import Bool exposing [Eq] import List import Num exposing [U8, U64, U128] +Sha256 := { location : U64, } -Sha256 := { - location : U64, -} - -Digest256 := { - firstHalf : U128, - secondHalf : U128, -} implements[Eq] +Digest256 := { firstHalf : U128, secondHalf : U128, } implements [Eq] emptySha256 : {} -> Sha256 @@ -29,22 +23,17 @@ sha256AddBytes : Sha256, List U8 -> Sha256 sha256Digest : Sha256 -> Digest256 hashSha256 : List U8 -> Digest256 -hashSha256 = \bytes -> - {} |> emptySha256 - |> sha256AddBytes bytes - |> sha256Digest +hashSha256 = \bytes -> {} |> emptySha256 |> sha256AddBytes bytes |> sha256Digest u128Bytes : U128 -> List U8 u128Bytes = \number -> - loop = \ n, bytes, place -> + loop = \n, bytes, place -> if place == 16 then bytes else - newByte = n - |> Num.bitwiseAnd 255 - |> Num.toU8 + newByte = n |> Num.bitwiseAnd 255 |> Num.toU8 loop (Num.shiftRightBy n 8) (List.prepend bytes newByte) (place + 1) loop number [] 0 digest256ToBytes : Digest256 -> List U8 -digest256ToBytes = \@Digest256{firstHalf, secondHalf} -> +digest256ToBytes = \@Digest256{ firstHalf, secondHalf } -> List.concat (u128Bytes firstHalf) (u128Bytes secondHalf) diff --git a/crates/compiler/gen_wasm/src/low_level.rs b/crates/compiler/gen_wasm/src/low_level.rs index 4defc53fc6..cb6a00d1a3 100644 --- a/crates/compiler/gen_wasm/src/low_level.rs +++ b/crates/compiler/gen_wasm/src/low_level.rs @@ -2178,7 +2178,9 @@ impl<'a> LowLevelCall<'a> { NumF64FromParts => self.load_args_and_call_zig(backend, bitcode::NUM_F64_FROM_PARTS), // Crypt CryptEmptySha256 => self.load_args_and_call_zig(backend, bitcode::CRYPT_EMPTY_SHA256), - CryptSha256AddBytes => self.load_args_and_call_zig(backend, bitcode::CRYPT_SHA256_ADD_BYTES), + CryptSha256AddBytes => { + self.load_args_and_call_zig(backend, bitcode::CRYPT_SHA256_ADD_BYTES) + } CryptSha256Digest => self.load_args_and_call_zig(backend, bitcode::CRYPT_SHA256_DIGEST), And => {