on master help sign in
add def of plusForeignPtr for older GHCs
commita40050f2d401c8b03e16cac81c7f5cf6307e5b3a authorHarendra Kumar <harendra.kumar@gmail.com> dateSun 16 Jun 2019, 15:23 (7 years ago) parentfb8e1d7
1 file changed+10−2
src/Streamly/Mem/Array/Types.hs+10−2
src/Streamly/Mem/Array/Types.hs+10−2
@@ -82,8 +82,7 @@ import Data.Functor.Identity (runIdentity)
8282import Data.Word (Word8)
8383import Foreign.C.String (CString)
8484import Foreign.C.Types (CSize(..), CInt(..))
85−import Foreign.ForeignPtr
86− (ForeignPtr, withForeignPtr, touchForeignPtr, plusForeignPtr)
85+import Foreign.ForeignPtr (ForeignPtr, withForeignPtr, touchForeignPtr)
8786import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
8887import Foreign.Ptr (plusPtr, minusPtr, castPtr, nullPtr)
8988import Foreign.Storable (Storable(..))
@@ -108,6 +107,15 @@ import qualified GHC.Exts as Exts
108107import qualified Data.Foldable as F
109108#endif
110109
110+#if MIN_VERSION_base(4,10,0)
111+import Foreign.ForeignPtr (plusForeignPtr)
112+#else
113+import GHC.Base (Int(..), plusAddr#)
114+import GHC.ForeignPtr (ForeignPtr(..))
115+plusForeignPtr :: ForeignPtr a -> Int -> ForeignPtr b
116+plusForeignPtr (ForeignPtr addr c) (I# d) = ForeignPtr (plusAddr# addr d) c
117+#endif
118+
111119-------------------------------------------------------------------------------
112120-- Design Notes
113121-------------------------------------------------------------------------------