Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow bytestring-0.11 #8

Merged
merged 1 commit into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cryptohash-sha256.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ library
Unsafe

build-depends: base >= 4.5 && < 4.15
, bytestring >= 0.9.2 && < 0.11
, bytestring >= 0.9.2 && < 0.12

ghc-options: -Wall

Expand Down
7 changes: 6 additions & 1 deletion src/Crypto/Hash/SHA256.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞

{-# LANGUAGE Trustworthy #-}

-- |
Expand Down Expand Up @@ -92,7 +93,7 @@ module Crypto.Hash.SHA256
import Data.Bits (xor)
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import Data.ByteString.Internal (ByteString (PS), create,
import Data.ByteString.Internal (ByteString (..), create,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞

createAndTrim, mallocByteString,
memcpy, toForeignPtr)
import qualified Data.ByteString.Lazy as L
Expand Down Expand Up @@ -136,7 +137,11 @@ create' :: Int -> (Ptr Word8 -> IO a) -> IO (ByteString,a)
create' l f = do
fp <- mallocByteString l
x <- withForeignPtr fp $ \p -> f p
#if MIN_VERSION_bytestring(0,11,0)
let bs = BS fp l
#else
let bs = PS fp 0 l
#endif
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return $! x `seq` bs `seq` (bs,x)

copyCtx :: Ptr Ctx -> Ptr Ctx -> IO ()
Expand Down