+#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
+ where
+ get i | i == count = return i
+ | otherwise = do
+ error_or_c <- try (hGetChar handle)
+ case error_or_c of
+ Left ex
+ | isEOFError ex -> return i
+ | otherwise -> ioError ex
+ Right c -> do
+ unsafeWrite arr i (fromIntegral (ord c))
+ 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
+ where
+ put i | i == count = return ()
+ | otherwise = do
+ w <- unsafeRead arr i
+ hPutChar handle (chr (fromIntegral w))
+ put (i+1)
+
+illegalBufferSize :: Handle -> String -> Int -> IO a
+illegalBufferSize _ fn sz = ioError $
+ userError (fn ++ ": illegal buffer size " ++ showsPrec 9 (sz::Int) [])
+#endif /* !__GLASGOW_HASKELL__ */