on master help sign in
Simplify the internal array code
eac9147Bryan O'Sullivan
Data/Text.hs+1−2
@@ -187,7 +187,6 @@ import Control.Monad.ST (ST)
187import qualified Data.Text.Array as A
187import qualified Data.Text.Array as A
188import qualified Data.List as L
188import qualified Data.List as L
189import Data.Monoid (Monoid(..))
189import Data.Monoid (Monoid(..))
190−import Data.Word (Word16)
191import Data.String (IsString(..))
190import Data.String (IsString(..))
192import qualified Data.Text.Fusion as S
191import qualified Data.Text.Fusion as S
193import qualified Data.Text.Fusion.Common as S
192import qualified Data.Text.Fusion.Common as S
@@ -308,7 +307,7 @@ append (Text arr1 off1 len1) (Text arr2 off2 len2) = Text (A.run x) 0 len
308 unstream (S.append (stream t1) (stream t2)) = append t1 t2
307 unstream (S.append (stream t1) (stream t2)) = append t1 t2
309 #-}
308 #-}
310
309
311−copy :: forall s. A.MArray s Word16 -> Int -> A.Array Word16 -> Int -> Int
310+copy :: forall s. A.MArray s -> Int -> A.Array -> Int -> Int
312 -> ST s ()
311 -> ST s ()
313copy dest i0 src j0 top = go i0 j0
312copy dest i0 src j0 top = go i0 j0
314 where
313 where
Data/Text/Array.hs+56−175
@@ -1,5 +1,4 @@
1−{-# LANGUAGE BangPatterns, CPP, ExistentialQuantification, MagicHash,
1+{-# LANGUAGE BangPatterns, CPP, MagicHash, Rank2Types, UnboxedTuples #-}
2− Rank2Types, ScopedTypeVariables, UnboxedTuples #-}
3{-# OPTIONS_GHC -fno-warn-unused-matches #-}
2{-# OPTIONS_GHC -fno-warn-unused-matches #-}
4-- |
3-- |
5-- Module : Data.Text.Array
4-- Module : Data.Text.Array
@@ -27,20 +26,20 @@ module Data.Text.Array
27 (
26 (
28 -- * Types
27 -- * Types
29 IArray(..)
28 IArray(..)
30− , Elt(..)
31 , Array
29 , Array
32 , MArray
30 , MArray
33
31
34 -- * Functions
32 -- * Functions
33+ , copy
35 , empty
34 , empty
36− , new
37− , unsafeNew
38− , unsafeFreeze
39 , run
35 , run
40 , run2
36 , run2
41 , toList
37 , toList
42− , copy
43 , unsafeCopy
38 , unsafeCopy
39+ , unsafeFreeze
40+ , unsafeIndex
41+ , unsafeNew
42+ , unsafeWrite
44 ) where
43 ) where
45
44
46#if 0
45#if 0
@@ -53,125 +52,48 @@ if (_k_) < 0 || (_k_) >= (_len_) then error ("Data.Text.Array." ++ (_func_) ++ "
53#define CHECK_BOUNDS(_func_,_len_,_k_)
52#define CHECK_BOUNDS(_func_,_len_,_k_)
54#endif
53#endif
55
54
56−#if defined(__GLASGOW_HASKELL__)
57#include "MachDeps.h"
55#include "MachDeps.h"
58
56
57+import Control.Exception (assert)
58+import Data.Text.UnsafeShift (shiftL)
59import GHC.Base (ByteArray#, MutableByteArray#, Int(..),
59import GHC.Base (ByteArray#, MutableByteArray#, Int(..),
60 indexWord16Array#, newByteArray#,
60 indexWord16Array#, newByteArray#,
61 readWord16Array#, unsafeCoerce#,
61 readWord16Array#, unsafeCoerce#,
62− writeWord16Array#, (*#))
62+ writeWord16Array#)
63−import GHC.Prim (Int#)
64import GHC.ST (ST(..), runST)
63import GHC.ST (ST(..), runST)
65import GHC.Word (Word16(..))
64import GHC.Word (Word16(..))
66−
67−#elif defined(__HUGS__)
68−
69−import Hugs.ByteArray (ByteArray, MutableByteArray, readByteArray,
70− newMutableByteArray, readMutableByteArray,
71− unsafeFreezeMutableByteArray, writeMutableByteArray)
72−import Foreign.Storable (Storable, sizeOf)
73−import Hugs.ST (ST(..), runST)
74−
75−#else
76−# error not implemented for this compiler
77−#endif
78−
79−import Control.Exception (assert)
80−import Data.Typeable (Typeable1(..), Typeable2(..), TyCon, mkTyCon, mkTyConApp)
81import Prelude hiding (length, read)
65import Prelude hiding (length, read)
82
66
83−#include "Typeable.h"
84−
85-- | Immutable array type.
67-- | Immutable array type.
86−data Array e = Array
68+data Array = Array
87− {-# UNPACK #-} !Int -- length (in units of e, not bytes)
69+ {-# UNPACK #-} !Int -- length (in units of Word16, not bytes)
88−#if defined(__GLASGOW_HASKELL__)
89 ByteArray#
70 ByteArray#
90−#elif defined(__HUGS__)
91− !ByteArray
92−#endif
93−
94−INSTANCE_TYPEABLE1(Array,arrayTc,"Array")
95
71
96-- | Mutable array type, for use in the ST monad.
72-- | Mutable array type, for use in the ST monad.
97−data MArray s e = MArray
73+data MArray s = MArray
98− {-# UNPACK #-} !Int -- length (in units of e, not bytes)
74+ {-# UNPACK #-} !Int -- length (in units of Word16, not bytes)
99−#if defined(__GLASGOW_HASKELL__)
100 (MutableByteArray# s)
75 (MutableByteArray# s)
101−#elif defined(__HUGS__)
102− !(MutableByteArray s)
103−#endif
104−
105−INSTANCE_TYPEABLE2(MArray,mArrayTc,"MArray")
106
76
107-- | Operations supported by all arrays.
77-- | Operations supported by all arrays.
108class IArray a where
78class IArray a where
109 -- | Return the length of an array.
79 -- | Return the length of an array.
110 length :: a -> Int
80 length :: a -> Int
111
81
112−instance IArray (Array e) where
82+instance IArray Array where
113 length (Array len _ba) = len
83 length (Array len _ba) = len
114 {-# INLINE length #-}
84 {-# INLINE length #-}
115
85
116−instance (Elt e, Show e) => Show (Array e) where
117− show = show . toList
118−
119−instance IArray (MArray s e) where
86+instance IArray (MArray s) where
120 length (MArray len _ba) = len
87 length (MArray len _ba) = len
121 {-# INLINE length #-}
88 {-# INLINE length #-}
122
89
123−check :: IArray a => String -> a -> Int -> (a -> Int -> b) -> b
124−check func ary i f
125− | i >= 0 && i < length ary = f ary i
126− | otherwise = error ("Data.Array.Flat." ++ func ++ ": index out of bounds")
127−{-# INLINE check #-}
128−
129−-- | Operations supported by all elements that can be stored in
130−-- arrays.
131−class Elt e where
132− -- | Indicate how many bytes would be used for an array of the
133− -- given size.
134− bytesInArray :: Int -> e -> Int
135− -- | Unchecked read of an immutable array. May return garbage or
136− -- crash on an out-of-bounds access.
137− unsafeIndex :: Array e -> Int -> e
138− -- | Unchecked read of a mutable array. May return garbage or
139− -- crash on an out-of-bounds access.
140− unsafeRead :: MArray s e -> Int -> ST s e
141− -- | Unchecked write of a mutable array. May return garbage or
142− -- crash on an out-of-bounds access.
143− unsafeWrite :: MArray s e -> Int -> e -> ST s ()
144−
145− -- | Read an immutable array. An invalid index results in a
146− -- runtime error.
147− index :: Array e -> Int -> e
148− index ary i = check "index" ary i unsafeIndex
149− {-# INLINE index #-}
150−
151− -- | Read a mutable array. An invalid index results in a runtime
152− -- error.
153− read :: Array e -> Int -> ST s e
154− read ary i = check "read" ary i read
155− {-# INLINE read #-}
156−
157− -- | Write a mutable array. An invalid index results in a runtime
158− -- error.
159− write :: Array e -> Int -> ST s e
160− write ary i = check "write" ary i write
161− {-# INLINE write #-}
162−
163-- | Freeze a mutable array. Do not mutate the 'MArray' afterwards!
90-- | Freeze a mutable array. Do not mutate the 'MArray' afterwards!
164−unsafeFreeze :: MArray s e -> ST s (Array e)
91+unsafeFreeze :: MArray s -> ST s (Array)
165−
166−#if defined(__GLASGOW_HASKELL__)
167−
168−wORD16_SCALE :: Int# -> Int#
169−wORD16_SCALE n# = scale# *# n# where !(I# scale#) = SIZEOF_WORD16
170
92
171-- | Create an uninitialized mutable array.
93-- | Create an uninitialized mutable array.
172−unsafeNew :: forall s e. Elt e => Int -> ST s (MArray s e)
94+unsafeNew :: forall s. Int -> ST s (MArray s)
173unsafeNew n = assert (n >= 0) . ST $ \s1# ->
95unsafeNew n = assert (n >= 0) . ST $ \s1# ->
174− case bytesInArray n (undefined :: e) of
96+ case bytesInArray n of
175 len@(I# len#) ->
97 len@(I# len#) ->
176#if defined(BOUNDS_CHECKING)
98#if defined(BOUNDS_CHECKING)
177 if len < 0 then error (show ("unsafeNew",len)) else
99 if len < 0 then error (show ("unsafeNew",len)) else
@@ -184,97 +106,57 @@ unsafeFreeze (MArray len mba#) = ST $ \s# ->
184 (# s#, Array len (unsafeCoerce# mba#) #)
106 (# s#, Array len (unsafeCoerce# mba#) #)
185{-# INLINE unsafeFreeze #-}
107{-# INLINE unsafeFreeze #-}
186
108
187−-- | Create a mutable array, with its elements initialized with the
109+-- | Indicate how many bytes would be used for an array of the given
188−-- given value.
110+-- size.
189−new :: forall s e. Elt e => Int -> e -> ST s (MArray s e)
111+bytesInArray :: Int -> Int
190−
112+bytesInArray n = n `shiftL` 1
191−#elif defined(__HUGS__)
113+{-# INLINE bytesInArray #-}
192−
114+
193−unsafeIndexArray :: Storable e => Array e -> Int -> e
115+-- | Unchecked read of an immutable array. May return garbage or
194−unsafeIndexArray (Array off len arr) i =
116+-- crash on an out-of-bounds access.
195− assert (i >= 0 && i < len) $ readByteArray arr (off + i)
117+unsafeIndex :: Array -> Int -> Word16
196−
197−unsafeReadMArray :: Storable e => MArray s e -> Int -> ST s e
198−unsafeReadMArray (MArray _len marr) i =
199− assert (i >= 0 && i < len) $ readMutableByteArray marr
200−
201−unsafeWriteMArray :: Storable e => MArray s e -> Int -> e -> ST s ()
202−unsafeWriteMArray (MArray len marr) i =
203− assert (i >= 0 && i < len) $ writeMutableByteArray marr
204−
205−-- | Create an uninitialized mutable array.
206−unsafeNew :: (Storable e) => Int -> ST s (MArray s e)
207−unsafeNew n = new undefined
208− where new :: (Storable e) => e -> ST s (MArray s e)
209− new unused = do
210− marr <- newMutableByteArray (n * sizeOf unused)
211− return (MArray n marr)
212−
213−unsafeFreeze (MArray len mba) = do
214− ba <- unsafeFreezeMutableByteArray mba
215− return (Array 0 len ba)
216−
217−-- | Create a mutable array, with its elements initialized with the
218−-- given value.
219−new :: (Storable e) => Int -> e -> ST s (MArray s e)
220−#endif
221−
222−new len initVal = do
223− marr <- unsafeNew len
224− sequence_ [unsafeWrite marr i initVal | i <- [0..len-1]]
225− return marr
226−
227−instance Elt Word16 where
228−#if defined(__GLASGOW_HASKELL__)
229−
230− bytesInArray (I# i#) _ = I# (wORD16_SCALE i#)
231− {-# INLINE bytesInArray #-}
232−
233− unsafeIndex (Array len ba#) i@(I# i#) =
118+unsafeIndex (Array len ba#) i@(I# i#) =
234− CHECK_BOUNDS("unsafeIndex",len,i)
119+ CHECK_BOUNDS("unsafeIndex",len,i)
235− case indexWord16Array# ba# i# of r# -> (W16# r#)
120+ case indexWord16Array# ba# i# of r# -> (W16# r#)
236− {-# INLINE unsafeIndex #-}
121+{-# INLINE unsafeIndex #-}
237−
122+
123+-- | Unchecked read of a mutable array. May return garbage or
124+-- crash on an out-of-bounds access.
125+unsafeRead :: MArray s -> Int -> ST s Word16
238− unsafeRead (MArray len mba#) i@(I# i#) = ST $ \s# ->
126+unsafeRead (MArray len mba#) i@(I# i#) = ST $ \s# ->
239− CHECK_BOUNDS("unsafeRead",len,i)
127+ CHECK_BOUNDS("unsafeRead",len,i)
240− case readWord16Array# mba# i# s# of
128+ case readWord16Array# mba# i# s# of
241− (# s2#, r# #) -> (# s2#, W16# r# #)
129+ (# s2#, r# #) -> (# s2#, W16# r# #)
242− {-# INLINE unsafeRead #-}
130+{-# INLINE unsafeRead #-}
243−
131+
132+-- | Unchecked write of a mutable array. May return garbage or crash
133+-- on an out-of-bounds access.
134+unsafeWrite :: MArray s -> Int -> Word16 -> ST s ()
244− unsafeWrite (MArray len marr#) i@(I# i#) (W16# e#) = ST $ \s1# ->
135+unsafeWrite (MArray len marr#) i@(I# i#) (W16# e#) = ST $ \s1# ->
245− CHECK_BOUNDS("unsafeWrite",len,i)
136+ CHECK_BOUNDS("unsafeWrite",len,i)
246− case writeWord16Array# marr# i# e# s1# of
137+ case writeWord16Array# marr# i# e# s1# of
247− s2# -> (# s2#, () #)
138+ s2# -> (# s2#, () #)
248− {-# INLINE unsafeWrite #-}
139+{-# INLINE unsafeWrite #-}
249−
250−#elif defined(__HUGS__)
251−
252− bytesInArray n w = sizeOf w * n
253− unsafeIndex = unsafeIndexArray
254− unsafeRead = unsafeReadMArray
255− unsafeWrite = unsafeWriteMArray
256−
257−#endif
258
140
259-- | Convert an immutable array to a list.
141-- | Convert an immutable array to a list.
260−toList :: Elt e => Array e -> [e]
142+toList :: Array -> [Word16]
261toList a = loop 0
143toList a = loop 0
262 where loop i | i < len = unsafeIndex a i : loop (i+1)
144 where loop i | i < len = unsafeIndex a i : loop (i+1)
263 | otherwise = []
145 | otherwise = []
264 len = length a
146 len = length a
265
147
266-- | An empty immutable array.
148-- | An empty immutable array.
267−empty :: Elt e => Array e
149+empty :: Array
268empty = runST (unsafeNew 0 >>= unsafeFreeze)
150empty = runST (unsafeNew 0 >>= unsafeFreeze)
269
151
270-- | Run an action in the ST monad and return an immutable array of
152-- | Run an action in the ST monad and return an immutable array of
271-- its result.
153-- its result.
272−run :: Elt e => (forall s. ST s (MArray s e)) -> Array e
154+run :: (forall s. ST s (MArray s)) -> Array
273run k = runST (k >>= unsafeFreeze)
155run k = runST (k >>= unsafeFreeze)
274
156
275-- | Run an action in the ST monad and return an immutable array of
157-- | Run an action in the ST monad and return an immutable array of
276-- its result paired with whatever else the action returns.
158-- its result paired with whatever else the action returns.
277−run2 :: Elt e => (forall s. ST s (MArray s e, a)) -> (Array e, a)
159+run2 :: (forall s. ST s (MArray s, a)) -> (Array, a)
278run2 k = runST (do
160run2 k = runST (do
279 (marr,b) <- k
161 (marr,b) <- k
280 arr <- unsafeFreeze marr
162 arr <- unsafeFreeze marr
@@ -282,8 +164,8 @@ run2 k = runST (do
282
164
283-- | Copy an array in its entirety. The destination array must be at
165-- | Copy an array in its entirety. The destination array must be at
284-- least as big as the source.
166-- least as big as the source.
285−copy :: Elt e => MArray s e -- ^ source array
167+copy :: MArray s -- ^ source array
286− -> MArray s e -- ^ destination array
168+ -> MArray s -- ^ destination array
287 -> ST s ()
169 -> ST s ()
288copy src dest
170copy src dest
289 | length dest >= length src = copy_loop 0
171 | length dest >= length src = copy_loop 0
@@ -297,8 +179,7 @@ copy src dest
297{-# INLINE copy #-}
179{-# INLINE copy #-}
298
180
299-- | Unsafely copy the elements of an array.
181-- | Unsafely copy the elements of an array.
300−unsafeCopy :: Elt e =>
301− MArray s e -> Int -> MArray s e -> Int -> Int -> ST s ()
182+unsafeCopy :: MArray s -> Int -> MArray s -> Int -> Int -> ST s ()
302unsafeCopy src sidx dest didx count =
183unsafeCopy src sidx dest didx count =
303 assert (sidx + count <= length src) .
184 assert (sidx + count <= length src) .
304 assert (didx + count <= length dest) $
185 assert (didx + count <= length dest) $
Data/Text/IO/Internal.hs+2−2
@@ -127,7 +127,7 @@ getSomeCharacters :: Handle__ -> CharBuffer -> IO CharBuffer
127getSomeCharacters handle_@Handle__{..} buf@Buffer{..} =
127getSomeCharacters handle_@Handle__{..} buf@Buffer{..} =
128 case bufferElems buf of
128 case bufferElems buf of
129 -- buffer empty: read some more
129 -- buffer empty: read some more
130− 0 -> readTextDevice handle_ buf
130+ 0 -> {-# SCC "readTextDevice" #-} readTextDevice handle_ buf
131
131
132 -- if the buffer has a single '\r' in it and we're doing newline
132 -- if the buffer has a single '\r' in it and we're doing newline
133 -- translation: read some more
133 -- translation: read some more
@@ -145,7 +145,7 @@ getSomeCharacters handle_@Handle__{..} buf@Buffer{..} =
145 return buf
145 return buf
146
146
147 -- buffer has some chars in it already: just return it
147 -- buffer has some chars in it already: just return it
148− _otherwise -> return buf
148+ _otherwise -> {-# SCC "otherwise" #-} return buf
149
149
150-- | Read a single chunk of strict text from a buffer. Used by both
150-- | Read a single chunk of strict text from a buffer. Used by both
151-- the strict and lazy implementations of hGetContents.
151-- the strict and lazy implementations of hGetContents.
Data/Text/Internal.hs+3−4
@@ -31,17 +31,16 @@ module Data.Text.Internal
31import Control.Exception (assert)
31import Control.Exception (assert)
32import qualified Data.Text.Array as A
32import qualified Data.Text.Array as A
33import Data.Typeable (Typeable)
33import Data.Typeable (Typeable)
34−import Data.Word (Word16)
35
34
36-- | A space efficient, packed, unboxed Unicode text type.
35-- | A space efficient, packed, unboxed Unicode text type.
37data Text = Text
36data Text = Text
38− {-# UNPACK #-} !(A.Array Word16) -- payload
37+ {-# UNPACK #-} !A.Array -- payload
39 {-# UNPACK #-} !Int -- offset
38 {-# UNPACK #-} !Int -- offset
40 {-# UNPACK #-} !Int -- length
39 {-# UNPACK #-} !Int -- length
41 deriving (Typeable)
40 deriving (Typeable)
42
41
43-- | Smart constructor.
42-- | Smart constructor.
44−text :: A.Array Word16 -> Int -> Int -> Text
43+text :: A.Array -> Int -> Int -> Text
45text arr off len =
44text arr off len =
46 assert (len >= 0) .
45 assert (len >= 0) .
47 assert (off >= 0) .
46 assert (off >= 0) .
@@ -59,7 +58,7 @@ empty = Text A.empty 0 0
59
58
60-- | Construct a 'Text' without invisibly pinning its byte array in
59-- | Construct a 'Text' without invisibly pinning its byte array in
61-- memory if its length has dwindled to zero.
60-- memory if its length has dwindled to zero.
62−textP :: A.Array Word16 -> Int -> Int -> Text
61+textP :: A.Array -> Int -> Int -> Text
63textP arr off len | len == 0 = empty
62textP arr off len | len == 0 = empty
64 | otherwise = text arr off len
63 | otherwise = text arr off len
65{-# INLINE textP #-}
64{-# INLINE textP #-}
Data/Text/Lazy/Builder.hs+9−11
@@ -38,7 +38,6 @@ import Data.Text.Internal (Text(..))
38import Data.Text.Lazy.Internal (smallChunkSize)
38import Data.Text.Lazy.Internal (smallChunkSize)
39import Data.Text.Unsafe (inlineInterleaveST)
39import Data.Text.Unsafe (inlineInterleaveST)
40import Data.Text.UnsafeShift (shiftR)
40import Data.Text.UnsafeShift (shiftR)
41−import Data.Word (Word16)
42import Prelude hiding (map, putChar)
41import Prelude hiding (map, putChar)
43
42
44import qualified Data.String as String
43import qualified Data.String as String
@@ -163,7 +162,7 @@ fromLazyText ts = flush `append` mapBuilder (L.toChunks ts ++)
163------------------------------------------------------------------------
162------------------------------------------------------------------------
164
163
165-- Our internal buffer type
164-- Our internal buffer type
166−data Buffer s = Buffer {-# UNPACK #-} !(A.MArray s Word16)
165+data Buffer s = Buffer {-# UNPACK #-} !(A.MArray s)
167 {-# UNPACK #-} !Int -- offset
166 {-# UNPACK #-} !Int -- offset
168 {-# UNPACK #-} !Int -- used units
167 {-# UNPACK #-} !Int -- used units
169 {-# UNPACK #-} !Int -- length left
168 {-# UNPACK #-} !Int -- length left
@@ -240,11 +239,11 @@ ensureFree !n = withSize $ \ l ->
240
239
241-- | Ensure that @n@ many elements are available, and then use @f@ to
240-- | Ensure that @n@ many elements are available, and then use @f@ to
242-- write some elements into the memory.
241-- write some elements into the memory.
243−writeN :: Int -> (forall s. A.MArray s Word16 -> Int -> ST s ()) -> Builder
242+writeN :: Int -> (forall s. A.MArray s -> Int -> ST s ()) -> Builder
244writeN n f = ensureFree n `append'` withBuffer (writeNBuffer n f)
243writeN n f = ensureFree n `append'` withBuffer (writeNBuffer n f)
245{-# INLINE [0] writeN #-}
244{-# INLINE [0] writeN #-}
246
245
247−writeNBuffer :: Int -> (A.MArray s Word16 -> Int -> ST s ()) -> (Buffer s)
246+writeNBuffer :: Int -> (A.MArray s -> Int -> ST s ()) -> (Buffer s)
248 -> ST s (Buffer s)
247 -> ST s (Buffer s)
249writeNBuffer n f (Buffer p o u l) = do
248writeNBuffer n f (Buffer p o u l) = do
250 f p (o+u)
249 f p (o+u)
@@ -258,8 +257,7 @@ newBuffer size = do
258{-# INLINE newBuffer #-}
257{-# INLINE newBuffer #-}
259
258
260-- | Unsafely copy the elements of an array.
259-- | Unsafely copy the elements of an array.
261−unsafeCopy :: A.Elt e =>
262− A.Array e -> Int -> A.MArray s e -> Int -> Int -> ST s ()
260+unsafeCopy :: A.Array -> Int -> A.MArray s -> Int -> Int -> ST s ()
263unsafeCopy src sidx dest didx count =
261unsafeCopy src sidx dest didx count =
264 assert (sidx + count <= A.length src) .
262 assert (sidx + count <= A.length src) .
265 assert (didx + count <= A.length dest) $
263 assert (didx + count <= A.length dest) $
@@ -273,7 +271,7 @@ unsafeCopy src sidx dest didx count =
273
271
274-- Write a character to the array, starting at the specified offset
272-- Write a character to the array, starting at the specified offset
275-- @i@. Returns the number of elements written.
273-- @i@. Returns the number of elements written.
276−unsafeWrite :: A.MArray s Word16 -> Int -> Char -> ST s Int
274+unsafeWrite :: A.MArray s -> Int -> Char -> ST s Int
277unsafeWrite marr i c
275unsafeWrite marr i c
278 | n < 0x10000 = do
276 | n < 0x10000 = do
279 assert (i >= 0) . assert (i < A.length marr) $
277 assert (i >= 0) . assert (i < A.length marr) $
@@ -302,13 +300,13 @@ append' (Builder f) (Builder g) = Builder (f . g)
302
300
303{-# RULES
301{-# RULES
304
302
305−"append/writeN" forall a b (f::forall s. A.MArray s Word16 -> Int -> ST s ())
303+"append/writeN" forall a b (f::forall s. A.MArray s -> Int -> ST s ())
306− (g::forall s. A.MArray s Word16 -> Int -> ST s ()) ws.
304+ (g::forall s. A.MArray s -> Int -> ST s ()) ws.
307 append (writeN a f) (append (writeN b g) ws) =
305 append (writeN a f) (append (writeN b g) ws) =
308 append (writeN (a+b) (\marr o -> f marr o >> g marr (o+a))) ws
306 append (writeN (a+b) (\marr o -> f marr o >> g marr (o+a))) ws
309
307
310−"writeN/writeN" forall a b (f::forall s. A.MArray s Word16 -> Int -> ST s ())
308+"writeN/writeN" forall a b (f::forall s. A.MArray s -> Int -> ST s ())
311− (g::forall s. A.MArray s Word16 -> Int -> ST s ()).
309+ (g::forall s. A.MArray s -> Int -> ST s ()).
312 append (writeN a f) (writeN b g) =
310 append (writeN a f) (writeN b g) =
313 writeN (a+b) (\marr o -> f marr o >> g marr (o+a))
311 writeN (a+b) (\marr o -> f marr o >> g marr (o+a))
314
312
Data/Text/UnsafeChar.hs+1−1
@@ -43,7 +43,7 @@ unsafeChr32 :: Word32 -> Char
43unsafeChr32 (W32# w#) = C# (chr# (word2Int# w#))
43unsafeChr32 (W32# w#) = C# (chr# (word2Int# w#))
44{-# INLINE unsafeChr32 #-}
44{-# INLINE unsafeChr32 #-}
45
45
46−unsafeWrite :: A.MArray s Word16 -> Int -> Char -> ST s Int
46+unsafeWrite :: A.MArray s -> Int -> Char -> ST s Int
47unsafeWrite marr i c
47unsafeWrite marr i c
48 | n < 0x10000 = do
48 | n < 0x10000 = do
49 assert (i >= 0) . assert (i < A.length marr) $
49 assert (i >= 0) . assert (i < A.length marr) $