From 4c022a01d14aa47330f3203e6b25e316a502f999 Mon Sep 17 00:00:00 2001 From: Ross Paterson Date: Thu, 10 Aug 2006 18:29:02 +0000 Subject: [PATCH] (non-GHC only) track MArray interface change --- Data/Array/IO.hs | 18 ++++++++++-------- Data/Array/IO/Internals.hs | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Data/Array/IO.hs b/Data/Array/IO.hs index 996879d..a476a32 100644 --- a/Data/Array/IO.hs +++ b/Data/Array/IO.hs @@ -226,10 +226,11 @@ illegalBufferSize handle fn sz = #else /* !__GLASGOW_HASKELL__ */ hGetArray :: Handle -> IOUArray Int Word8 -> Int -> IO Int -hGetArray handle arr count - | count < 0 || count > rangeSize (bounds arr) - = illegalBufferSize handle "hGetArray" count - | otherwise = get 0 +hGetArray handle arr count = do + bds <- getBounds arr + if count < 0 || count > rangeSize bds + then illegalBufferSize handle "hGetArray" count + else get 0 where get i | i == count = return i | otherwise = do @@ -243,10 +244,11 @@ hGetArray handle arr count get (i+1) hPutArray :: Handle -> IOUArray Int Word8 -> Int -> IO () -hPutArray handle arr count - | count < 0 || count > rangeSize (bounds arr) - = illegalBufferSize handle "hPutArray" count - | otherwise = put 0 +hPutArray handle arr count = do + bds <- getBounds arr + if count < 0 || count > rangeSize bds + then illegalBufferSize handle "hPutArray" count + else put 0 where put i | i == count = return () | otherwise = do diff --git a/Data/Array/IO/Internals.hs b/Data/Array/IO/Internals.hs index 433c6c2..fca542e 100644 --- a/Data/Array/IO/Internals.hs +++ b/Data/Array/IO/Internals.hs @@ -50,7 +50,7 @@ INSTANCE_TYPEABLE2(IOArray,iOArrayTc,"IOArray") instance MArray IOArray e IO where #if defined(__HUGS__) - getBound = return . boundsIOArray + getBounds = return . boundsIOArray #elif defined(__GLASGOW_HASKELL__) {-# INLINE getBounds #-} getBounds (IOArray marr) = stToIO $ getBounds marr -- 1.7.10.4