diff --git a/ghc/lib/exts/ByteArray.lhs b/ghc/lib/exts/ByteArray.lhs
index 6fba8e150bdef72a087118a71152c35edadda9bc..504b2eb2a4bbb06348d6b1fb621fd80b73d8ad88 100644
--- a/ghc/lib/exts/ByteArray.lhs
+++ b/ghc/lib/exts/ByteArray.lhs
@@ -13,16 +13,26 @@ module ByteArray
         Ix,
 
         --Indexing of ordinary @Arrays@ is standard Haskell and isn't defined here.
-        indexCharArray,     -- :: Ix ix => ByteArray ix -> ix -> Char 
-        indexIntArray,      -- :: Ix ix => ByteArray ix -> ix -> Int
-        indexWordArray,     -- :: Ix ix => ByteArray ix -> ix -> Word
-        indexAddrArray,     -- :: Ix ix => ByteArray ix -> ix -> Addr
-        indexFloatArray,    -- :: Ix ix => ByteArray ix -> ix -> Float
-        indexDoubleArray,   -- :: Ix ix => ByteArray ix -> ix -> Double
-
+        indexCharArray,       -- :: Ix ix => ByteArray ix -> ix -> Char 
+        indexIntArray,        -- :: Ix ix => ByteArray ix -> ix -> Int
+        indexWordArray,       -- :: Ix ix => ByteArray ix -> ix -> Word
+        indexAddrArray,       -- :: Ix ix => ByteArray ix -> ix -> Addr
+        indexFloatArray,      -- :: Ix ix => ByteArray ix -> ix -> Float
+        indexDoubleArray,     -- :: Ix ix => ByteArray ix -> ix -> Double
+        indexStablePtrArray   -- :: Ix ix => ByteArray ix -> ix -> (StablePtr a)
+ 
        ) where
 
 import PrelArr
+import PrelBase
+import PrelForeign
 import Ix
 \end{code}
 
+\begin{code}
+indexStablePtrArray    :: Ix ix => ByteArray ix -> ix -> (StablePtr a)
+indexStablePtrArray (ByteArray ixs barr#) n
+  = case (index ixs n)	    	    	of { I# n# ->
+    case indexStablePtrArray# barr# n# 	of { r# ->
+    (StablePtr r#)}}
+\end{code}