From: simonm Date: Tue, 6 Oct 1998 14:36:27 +0000 (+0000) Subject: [project @ 1998-10-06 14:36:27 by simonm] X-Git-Tag: Approx_2487_patches~246 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=e363c98b95457881c26c9e51da0df423697ac290;p=ghc-hetmet.git [project @ 1998-10-06 14:36:27 by simonm] back out revision 1.2 (change made on wrong branch). --- diff --git a/ghc/lib/misc/CString.lhs b/ghc/lib/misc/CString.lhs index 48c1f55..26b775e 100644 --- a/ghc/lib/misc/CString.lhs +++ b/ghc/lib/misc/CString.lhs @@ -54,7 +54,10 @@ module CString import PrelPack import GlaExts import Addr -import PrelIOBase ( IO(..) ) +import PrelIOBase ( IO(..), IOResult(..)) +import PrelArr ( StateAndMutableByteArray#(..), + StateAndByteArray#(..) + ) \end{code} @@ -161,21 +164,21 @@ out the bounds - use with care. allocChars :: Int -> IO (MutableByteArray RealWorld Int) allocChars (I# size#) = IO $ \ s# -> case newCharArray# size# s# of - (# s2#, barr# #) -> - (# s2#, (MutableByteArray (I# 1#, I# size#) barr#) #) + StateAndMutableByteArray# s2# barr# -> + IOok s2# (MutableByteArray (I# 1#, I# size#) barr#) allocWords :: Int -> IO (MutableByteArray RealWorld Int) allocWords (I# size#) = IO $ \ s# -> case newIntArray# size# s# of - (# s2#, barr# #) -> - (# s2#, (MutableByteArray (I# 1#, I# size#) barr#) #) + StateAndMutableByteArray# s2# barr# -> + IOok s2# (MutableByteArray (I# 1#, I# size#) barr#) -- Freeze these index-free mutable arrays freeze :: MutableByteArray RealWorld Int -> IO (ByteArray Int) freeze (MutableByteArray ixs arr#) = IO $ \ s# -> case unsafeFreezeByteArray# arr# s# of - (# s2#, frozen# #) -> - (# s2#, (ByteArray ixs frozen#) #) + StateAndByteArray# s2# frozen# -> + IOok s2# (ByteArray ixs frozen#) -- Copy a null-terminated string from outside the heap to -- Haskellized nonsense inside the heap