diff --git a/src/Crypto/Saltine/Instances.hs b/src/Crypto/Saltine/Instances.hs index e4b812212..b81d9560f 100644 --- a/src/Crypto/Saltine/Instances.hs +++ b/src/Crypto/Saltine/Instances.hs @@ -1,5 +1,4 @@ -{-# LANGUAGE BangPatterns #-} -{-# OPTIONS_GHC -Wwarn #-} +{-# OPTIONS_GHC -Wwarn -fno-warn-orphans #-} -- SPDX-FileCopyrightText: 2024 Sarah Vaupel -- @@ -50,7 +49,7 @@ buildUnsafeByteString' n k = do -- | Convenience function for accessing constant C strings constByteStrings :: [ByteString] -> ([CStringLen] -> IO b) -> IO b constByteStrings = - foldr (\v kk -> \k -> (unsafeUseAsCStringLen v) (\a -> kk (\as -> k (a:as)))) ($ []) + foldr (\v kk k -> unsafeUseAsCStringLen v (\a -> kk (\as -> k (a:as)))) ($ []) -- | bin2hex conversion for showing various binary types foreign import ccall unsafe "sodium_bin2hex" @@ -64,8 +63,9 @@ foreign import ccall unsafe "sodium_bin2hex" bin2hex :: ByteString -> String bin2hex bs = let tlen = S.length bs * 2 + 1 in S8.unpack . S8.init . snd . buildUnsafeByteString tlen $ \t -> - constByteStrings [bs] $ \[(pbs, _)] -> - c_sodium_bin2hex t (fromIntegral tlen) pbs (fromIntegral $ S.length bs) + let aux [(pbs, _)] = c_sodium_bin2hex t (fromIntegral tlen) pbs (fromIntegral $ S.length bs) + aux _ = error "Crypto.Saltine.Instances.bin2hex reached an impossible computation path" + in constByteStrings [bs] aux instance Show Key where show k = "SecretBox.Key {hashesTo = \"" <> (bin2hex . shorthash nullShKey $ encode k) <> "}\""