summaryrefslogtreecommitdiff
path: root/libraries/ghci
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-12-03 18:54:54 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-03 08:12:29 -0500
commitd8dc0f96237fe6fe7081c04727c7c2573477e5cb (patch)
treedbc4e8d25cf5a085e979df98bacad5999bf78aee /libraries/ghci
parenteea96042f1e8682605ae68db10f2bcdd7dab923e (diff)
downloadhaskell-d8dc0f96237fe6fe7081c04727c7c2573477e5cb.tar.gz
Fix array and cleanup conversion primops (#19026)
The first change makes the array ones use the proper fixed-size types, which also means that just like before, they can be used without explicit conversions with the boxed sized types. (Before, it was Int# / Word# on both sides, now it is fixed sized on both sides). For the second change, don't use "extend" or "narrow" in some of the user-facing primops names for conversions. - Names like `narrowInt32#` are misleading when `Int` is 32-bits. - Names like `extendInt64#` are flat-out wrong when `Int is 32-bits. - `narrow{Int,Word}<N>#` however map a type to itself, and so don't suffer from this problem. They are left as-is. These changes are batched together because Alex happend to use the array ops. We can only use released versions of Alex at this time, sadly, and I don't want to have to have a release thatwon't work for the final GHC 9.2. So by combining these we get all the changes for Alex done at once. Bump hackage state in a few places, and also make that workflow slightly easier for the future. Bump minimum Alex version Bump Cabal, array, bytestring, containers, text, and binary submodules
Diffstat (limited to 'libraries/ghci')
-rw-r--r--libraries/ghci/GHCi/BreakArray.hs26
1 files changed, 8 insertions, 18 deletions
diff --git a/libraries/ghci/GHCi/BreakArray.hs b/libraries/ghci/GHCi/BreakArray.hs
index 05d13bda67..18c1d96b30 100644
--- a/libraries/ghci/GHCi/BreakArray.hs
+++ b/libraries/ghci/GHCi/BreakArray.hs
@@ -32,20 +32,10 @@ import Control.Monad
import Data.Word
import GHC.Word
-import GHC.Exts hiding (extendWord8#, narrowWord8#)
+import GHC.Exts
import GHC.IO ( IO(..) )
import System.IO.Unsafe ( unsafeDupablePerformIO )
-#if MIN_VERSION_base(4,16,0)
-import GHC.Base (extendWord8#, narrowWord8#)
-#else
-narrowWord8#, extendWord8# :: Word# -> Word#
-narrowWord8# w = w
-extendWord8# w = w
-{-# INLINE narrowWord8# #-}
-{-# INLINE extendWord8# #-}
-#endif
-
data BreakArray = BA (MutableByteArray# RealWorld)
breakOff, breakOn :: Word8
@@ -104,22 +94,22 @@ newBreakArray :: Int -> IO BreakArray
newBreakArray entries@(I# sz) = do
BA array <- allocBA entries
case breakOff of
- W8# off -> do
+ off -> do
let loop n | isTrue# (n ==# sz) = return ()
- | otherwise = do writeBA# array n (extendWord8# off); loop (n +# 1#)
+ | otherwise = do writeBA# array n off; loop (n +# 1#)
loop 0#
return $ BA array
-writeBA# :: MutableByteArray# RealWorld -> Int# -> Word# -> IO ()
-writeBA# array i word = IO $ \s ->
- case writeWord8Array# array i word s of { s -> (# s, () #) }
+writeBA# :: MutableByteArray# RealWorld -> Int# -> Word8 -> IO ()
+writeBA# array i (W8# w) = IO $ \s ->
+ case writeWord8Array# array i w s of { s -> (# s, () #) }
writeBreakArray :: BreakArray -> Int -> Word8 -> IO ()
-writeBreakArray (BA array) (I# i) (W8# word) = writeBA# array i (extendWord8# word)
+writeBreakArray (BA array) (I# i) word = writeBA# array i word
readBA# :: MutableByteArray# RealWorld -> Int# -> IO Word8
readBA# array i = IO $ \s ->
- case readWord8Array# array i s of { (# s, c #) -> (# s, W8# (narrowWord8# c) #) }
+ case readWord8Array# array i s of { (# s, c #) -> (# s, W8# c #) }
readBreakArray :: BreakArray -> Int -> IO Word8
readBreakArray (BA array) (I# i) = readBA# array i