From 5f2b610a1f208978da10fbbdb52b7716c8137e2a Mon Sep 17 00:00:00 2001 From: Simon Marlow <marlowsd@gmail.com> Date: Mon, 2 Feb 2009 13:12:15 +0000 Subject: [PATCH] Update for new IO library (TEMPORARY: hGetArray/hPutArray not implemented) --- Data/Array/Base.hs | 6 ++++++ Data/Array/IO.hs | 24 +++++++++++++++++------- Data/Array/IO/Internals.hs | 4 ++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Data/Array/Base.hs b/Data/Array/Base.hs index bf0e5f01..f9cc0c5b 100644 --- a/Data/Array/Base.hs +++ b/Data/Array/Base.hs @@ -43,8 +43,14 @@ import GHC.Float ( Float(..), Double(..) ) import GHC.Stable ( StablePtr(..) ) import GHC.Int ( Int8(..), Int16(..), Int32(..), Int64(..) ) import GHC.Word ( Word8(..), Word16(..), Word32(..), Word64(..) ) +#if __GLASGOW_HASKELL__ >= 611 +import GHC.IO ( IO(..), stToIO ) +import GHC.IOArray ( IOArray(..), + newIOArray, unsafeReadIOArray, unsafeWriteIOArray ) +#else import GHC.IOBase ( IO(..), IOArray(..), stToIO, newIOArray, unsafeReadIOArray, unsafeWriteIOArray ) +#endif #else import Data.Int import Data.Word diff --git a/Data/Array/IO.hs b/Data/Array/IO.hs index 5f5166fc..13f46a45 100644 --- a/Data/Array/IO.hs +++ b/Data/Array/IO.hs @@ -1,4 +1,5 @@ {-# OPTIONS_GHC -#include "HsBase.h" #-} +{-# OPTIONS_GHC -w #-} --tmp ----------------------------------------------------------------------------- -- | -- Module : Data.Array.IO @@ -39,9 +40,11 @@ import Foreign import Foreign.C import GHC.Arr +import GHC.IORef +import GHC.IO.Handle +import GHC.IO.Buffer +import GHC.IO.Exception -import GHC.IOBase -import GHC.Handle #else import Data.Char import Data.Word ( Word8 ) @@ -63,6 +66,10 @@ hGetArray -- read, which might be smaller than the number requested -- if the end of file was reached. +hGetArray = undefined + +#if 0 + hGetArray handle (IOUArray (STUArray _l _u n ptr)) count | count == 0 = return 0 @@ -105,6 +112,8 @@ readChunk fd is_stream ptr init_off bytes0 = loop init_off bytes0 then return (off - init_off) else loop (off + r) (bytes - r) +#endif + -- --------------------------------------------------------------------------- -- hPutArray @@ -115,6 +124,10 @@ hPutArray -> Int -- ^ Number of 'Word8's to write -> IO () +hPutArray = undefined + +#if 0 + hPutArray handle (IOUArray (STUArray _l _u n raw)) count | count == 0 = return () @@ -144,14 +157,11 @@ hPutArray handle (IOUArray (STUArray _l _u n raw)) count flushWriteBuffer fd stream this_buf return () +#endif + -- --------------------------------------------------------------------------- -- Internal Utils -foreign import ccall unsafe "__hscore_memcpy_dst_off" - memcpy_baoff_ba :: RawBuffer -> CInt -> RawBuffer -> CSize -> IO (Ptr ()) -foreign import ccall unsafe "__hscore_memcpy_src_off" - memcpy_ba_baoff :: RawBuffer -> RawBuffer -> CInt -> CSize -> IO (Ptr ()) - illegalBufferSize :: Handle -> String -> Int -> IO a illegalBufferSize handle fn sz = ioException (ioeSetErrorString diff --git a/Data/Array/IO/Internals.hs b/Data/Array/IO/Internals.hs index 7c0cd61d..3569b79f 100644 --- a/Data/Array/IO/Internals.hs +++ b/Data/Array/IO/Internals.hs @@ -38,7 +38,11 @@ import Data.Array.Base import Data.Ix #ifdef __GLASGOW_HASKELL__ +#if __GLASGOW_HASKELL__ >= 611 +import GHC.IOArray (IOArray(..)) +#else import GHC.IOBase (IOArray(..)) +#endif #endif /* __GLASGOW_HASKELL__ */ #include "Typeable.h" -- GitLab