Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use CPP to ensure compilation on GHC 7.0.x

Foreign.Unsafe was only introduced in later GHC versions and made mandatory
after GHC 7.6.
  • Loading branch information...
commit 5e07b2cd7645aee03d737a5d2750748dbd360076 1 parent 9a2c812
@meiersi authored
View
8 Blaze/ByteString/Builder/ByteString.hs
@@ -37,8 +37,13 @@ module Blaze.ByteString.Builder.ByteString
import Blaze.ByteString.Builder.Internal hiding (insertByteString)
import qualified Blaze.ByteString.Builder.Internal as I (insertByteString)
+#ifdef HAS_FOREIGN_UNSAFE_MODULE
import Foreign (withForeignPtr, touchForeignPtr, copyBytes, plusPtr, minusPtr)
import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
+#else
+import Foreign (unsafeForeignPtrToPtr, withForeignPtr, touchForeignPtr, copyBytes, plusPtr, minusPtr)
+#endif
+
import Data.Monoid
import qualified Data.ByteString as S
@@ -48,7 +53,8 @@ import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString.Base as S
import qualified Data.ByteString.Lazy.Base as L -- FIXME: check if this is the right module
#else
-import qualified Data.ByteString.Internal as S
+import qualified Data.ByteString.Internal as S
+import qualified Data.ByteString.Lazy.Internal as L
#endif
View
4 Blaze/ByteString/Builder/Internal.hs
@@ -49,8 +49,12 @@ module Blaze.ByteString.Builder.Internal (
, defaultMaximalCopySize
) where
+#ifdef HAS_FOREIGN_UNSAFE_MODULE
import Foreign (withForeignPtr, sizeOf, copyBytes, plusPtr, minusPtr)
import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
+#else
+import Foreign (unsafeForeignPtrToPtr, withForeignPtr, sizeOf, copyBytes, plusPtr, minusPtr)
+#endif
import Control.Monad (unless)
View
5 Blaze/ByteString/Builder/Internal/Buffer.hs
@@ -40,9 +40,12 @@ module Blaze.ByteString.Builder.Internal.Buffer (
, runPut
) where
-import Prelude
+#ifdef HAS_FOREIGN_UNSAFE_MODULE
import Foreign (Word8, ForeignPtr, Ptr, plusPtr, minusPtr)
import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
+#else
+import Foreign (unsafeForeignPtrToPtr, Word8, ForeignPtr, Ptr, plusPtr, minusPtr)
+#endif
import qualified Data.ByteString as S
View
5 blaze-builder.cabal
@@ -49,6 +49,11 @@ Source-repository head
Library
ghc-options: -Wall
+ -- Earlier versions of GHC did not split off unsafe functions in "Foreign"
+ if impl(ghc >= 7.4)
+ cpp-options: -DHAS_FOREIGN_UNSAFE_MODULE
+
+
exposed-modules: Blaze.ByteString.Builder
Blaze.ByteString.Builder.Int
Blaze.ByteString.Builder.Word
Please sign in to comment.
Something went wrong with that request. Please try again.