From f31810517ee34c894286e0b9566f87eaaafd5f09 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sun, 19 Feb 2012 14:58:59 -0500 Subject: [PATCH 1/3] Add Num to constraints with Bits Bits no longer implies Num as of GHC 7.5 --- OpenSSL/Utils.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSSL/Utils.hs b/OpenSSL/Utils.hs index d38213a..1e12bda 100644 --- a/OpenSSL/Utils.hs +++ b/OpenSSL/Utils.hs @@ -45,7 +45,7 @@ raiseOpenSSLError :: IO a raiseOpenSSLError = getError >>= errorString >>= fail -- | Convert an integer to a hex string -toHex :: (Bits i) => i -> String +toHex :: (Num i, Bits i) => i -> String toHex = reverse . map hexByte . unfoldr step where step 0 = Nothing step i = Just (i .&. 0xf, i `shiftR` 4) @@ -69,7 +69,7 @@ toHex = reverse . map hexByte . unfoldr step where hexByte _ = undefined -- | Convert a hex string to an integer -fromHex :: (Bits i) => String -> i +fromHex :: (Num i, Bits i) => String -> i fromHex = foldl step 0 where step acc hexchar = (acc `shiftL` 4) .|. byteHex hexchar From a18f44c2a11189a0a96cd29b65c0ac053b2022b4 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sun, 19 Feb 2012 14:59:53 -0500 Subject: [PATCH 2/3] Use unsafePerformIO from System.IO.Unsafe Foreign.unsafePerformIO is deprecated as of GHC 7.5 --- OpenSSL/DSA.hsc | 3 ++- OpenSSL/EVP/Base64.hsc | 3 ++- OpenSSL/EVP/Digest.hsc | 3 ++- OpenSSL/EVP/Open.hsc | 3 ++- OpenSSL/RSA.hsc | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/OpenSSL/DSA.hsc b/OpenSSL/DSA.hsc index 840b96f..395a52c 100644 --- a/OpenSSL/DSA.hsc +++ b/OpenSSL/DSA.hsc @@ -34,7 +34,8 @@ module OpenSSL.DSA import Control.Monad import qualified Data.ByteString as BS import Data.Typeable -import Foreign +import Foreign hiding (unsafePerformIO) +import System.IO.Unsafe (unsafePerformIO) import Foreign.C (CString) import Foreign.C.Types import OpenSSL.BN diff --git a/OpenSSL/EVP/Base64.hsc b/OpenSSL/EVP/Base64.hsc index 06ad820..ef8fa7c 100644 --- a/OpenSSL/EVP/Base64.hsc +++ b/OpenSSL/EVP/Base64.hsc @@ -22,8 +22,9 @@ import qualified Data.ByteString.Lazy.Internal as L8Internal import qualified Data.ByteString.Char8 as B8 import qualified Data.ByteString.Lazy.Char8 as L8 import Data.List -import Foreign +import Foreign hiding (unsafePerformIO) import Foreign.C +import System.IO.Unsafe (unsafePerformIO) -- On encoding, we keep fetching the next block until we get at least diff --git a/OpenSSL/EVP/Digest.hsc b/OpenSSL/EVP/Digest.hsc index c399f1b..7153584 100644 --- a/OpenSSL/EVP/Digest.hsc +++ b/OpenSSL/EVP/Digest.hsc @@ -24,7 +24,8 @@ import Data.ByteString.Unsafe (unsafeUseAsCStringLen) import qualified Data.ByteString.Char8 as B8 import qualified Data.ByteString.Lazy.Char8 as L8 import Control.Applicative ((<$>)) -import Foreign +import Foreign hiding (unsafePerformIO) +import System.IO.Unsafe (unsafePerformIO) import Foreign.C import OpenSSL.EVP.Internal import OpenSSL.Objects diff --git a/OpenSSL/EVP/Open.hsc b/OpenSSL/EVP/Open.hsc index 63adcab..4a6f2a6 100644 --- a/OpenSSL/EVP/Open.hsc +++ b/OpenSSL/EVP/Open.hsc @@ -12,7 +12,8 @@ module OpenSSL.EVP.Open import qualified Data.ByteString.Char8 as B8 import qualified Data.ByteString.Lazy.Char8 as L8 -import Foreign +import Foreign hiding (unsafePerformIO) +import System.IO.Unsafe (unsafePerformIO) import Foreign.C import OpenSSL.EVP.Cipher hiding (cipher) import OpenSSL.EVP.PKey diff --git a/OpenSSL/RSA.hsc b/OpenSSL/RSA.hsc index f1853e8..86d27cf 100644 --- a/OpenSSL/RSA.hsc +++ b/OpenSSL/RSA.hsc @@ -32,7 +32,8 @@ module OpenSSL.RSA import Control.Monad import Data.Typeable -import Foreign +import Foreign hiding (unsafePerformIO) +import System.IO.Unsafe (unsafePerformIO) import Foreign.C import OpenSSL.BN import OpenSSL.Utils From 0b57510ea9db7dc2b26f2c6025e25c34851928b2 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sun, 19 Feb 2012 15:10:24 -0500 Subject: [PATCH 3/3] Use unsafeForeignPtrToPtr from Foreign.ForeignPtr.Unsafe Export from Foreign.ForeignPtr deprecated as of GHC 7.5 --- OpenSSL/EVP/Internal.hsc | 3 ++- OpenSSL/X509.hsc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/OpenSSL/EVP/Internal.hsc b/OpenSSL/EVP/Internal.hsc index 4ae3b1f..de090cb 100644 --- a/OpenSSL/EVP/Internal.hsc +++ b/OpenSSL/EVP/Internal.hsc @@ -61,7 +61,8 @@ import Foreign.Ptr (Ptr, castPtr, FunPtr) import Foreign.C.String (peekCStringLen) import Foreign.ForeignPtr ( ForeignPtr, newForeignPtr, withForeignPtr, addForeignPtrFinalizer, - mallocForeignPtrBytes, touchForeignPtr, unsafeForeignPtrToPtr) + mallocForeignPtrBytes, touchForeignPtr) +import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) import Foreign.Storable (Storable(..)) import Foreign.Marshal.Alloc (alloca, allocaBytes) import Foreign.Marshal.Array (allocaArray) diff --git a/OpenSSL/X509.hsc b/OpenSSL/X509.hsc index 42469a3..599375f 100644 --- a/OpenSSL/X509.hsc +++ b/OpenSSL/X509.hsc @@ -53,7 +53,8 @@ module OpenSSL.X509 import Control.Monad import Data.Time.Clock import Data.Maybe -import Foreign +import Foreign hiding (unsafeForeignPtrToPtr) +import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr) import Foreign.C import OpenSSL.ASN1 import OpenSSL.BIO