on master help sign in
Update the Unboxed representation
e3e60caAdithya Kumar
core/src/Streamly/Internal/Data/Array/Unboxed.hs+1−2
@@ -134,7 +134,6 @@ import Streamly.Internal.Data.Tuple.Strict (Tuple3Fused'(..))
134import Streamly.Internal.Data.Unfold.Type (Unfold(..))
134import Streamly.Internal.Data.Unfold.Type (Unfold(..))
135import Streamly.Internal.System.IO (unsafeInlineIO)
135import Streamly.Internal.System.IO (unsafeInlineIO)
136
136
137−import qualified Foreign.Storable as Storable
138import qualified Streamly.Internal.Data.Array.Unboxed.Mut.Type as MA
137import qualified Streamly.Internal.Data.Array.Unboxed.Mut.Type as MA
139import qualified Streamly.Internal.Data.Array.Unboxed.Mut as MA
138import qualified Streamly.Internal.Data.Array.Unboxed.Mut as MA
140import qualified Streamly.Internal.Data.Array.Unboxed.Type as A
139import qualified Streamly.Internal.Data.Array.Unboxed.Type as A
@@ -269,7 +268,7 @@ last = getIndexRev 0
269-- @since 0.8.0
268-- @since 0.8.0
270{-# INLINE writeLastN #-}
269{-# INLINE writeLastN #-}
271writeLastN ::
270writeLastN ::
272− (Unboxed a, Storable.Storable a, MonadIO m) => Int -> Fold m a (Array a)
271+ (Unboxed a, MonadIO m) => Int -> Fold m a (Array a)
273writeLastN n
272writeLastN n
274 | n <= 0 = fmap (const mempty) FL.drain
273 | n <= 0 = fmap (const mempty) FL.drain
275 | otherwise = A.unsafeFreeze <$> Fold step initial done
274 | otherwise = A.unsafeFreeze <$> Fold step initial done
core/src/Streamly/Internal/Data/Array/Unboxed/Mut/Type.hs+11−11
@@ -17,7 +17,7 @@ module Streamly.Internal.Data.Array.Unboxed.Mut.Type
17 -- * Type
17 -- * Type
18 -- $arrayNotes
18 -- $arrayNotes
19 Array (..)
19 Array (..)
20− , ArrayContents
20+ , MutableByteArray
21 , nilArrayContents
21 , nilArrayContents
22 , touch
22 , touch
23 , pin
23 , pin
@@ -226,7 +226,7 @@ import Data.Word (Word8)
226import Foreign.C.Types (CSize(..), CInt(..))
226import Foreign.C.Types (CSize(..), CInt(..))
227import Foreign.Ptr (plusPtr, minusPtr, nullPtr)
227import Foreign.Ptr (plusPtr, minusPtr, nullPtr)
228import Streamly.Internal.Data.Unboxed
228import Streamly.Internal.Data.Unboxed
229− ( ArrayContents(..)
229+ ( MutableByteArray(..)
230 , Unboxed
230 , Unboxed
231 , alignment
231 , alignment
232 , castContents
232 , castContents
@@ -341,7 +341,7 @@ data Array a =
341 -- The array is a range into arrContents. arrContents may be a superset of
341 -- The array is a range into arrContents. arrContents may be a superset of
342 -- the slice represented by the array. All offsets are in bytes.
342 -- the slice represented by the array. All offsets are in bytes.
343 Array
343 Array
344− { arrContents :: {-# UNPACK #-} !(ArrayContents a)
344+ { arrContents :: {-# UNPACK #-} !(MutableByteArray a)
345 , arrStart :: {-# UNPACK #-} !Int -- ^ index into arrContents
345 , arrStart :: {-# UNPACK #-} !Int -- ^ index into arrContents
346 , arrEnd :: {-# UNPACK #-} !Int -- ^ index into arrContents
346 , arrEnd :: {-# UNPACK #-} !Int -- ^ index into arrContents
347 -- Represents the first invalid index of
347 -- Represents the first invalid index of
@@ -391,7 +391,7 @@ unpin arr@Array{..} = do
391-- /Pre-release/
391-- /Pre-release/
392{-# INLINE newArrayWith #-}
392{-# INLINE newArrayWith #-}
393newArrayWith :: forall m a. (MonadIO m, Unboxed a)
393newArrayWith :: forall m a. (MonadIO m, Unboxed a)
394− => (Int -> Int -> m (ArrayContents a)) -> Int -> Int -> m (Array a)
394+ => (Int -> Int -> m (MutableByteArray a)) -> Int -> Int -> m (Array a)
395newArrayWith alloc alignSize count = do
395newArrayWith alloc alignSize count = do
396 let size = max (count * SIZE_OF(a)) 0
396 let size = max (count * SIZE_OF(a)) 0
397 contents <- alloc size alignSize
397 contents <- alloc size alignSize
@@ -405,17 +405,17 @@ newArrayWith alloc alignSize count = do
405-- XXX Move this to Unboxed and rename this to newPinnedAlignedBytes?
405-- XXX Move this to Unboxed and rename this to newPinnedAlignedBytes?
406-- XXX Similarly have newUnpinnedBytes
406-- XXX Similarly have newUnpinnedBytes
407{-# INLINE newAlignedArrayContents #-}
407{-# INLINE newAlignedArrayContents #-}
408−newAlignedArrayContents :: Int -> Int -> IO (ArrayContents a)
408+newAlignedArrayContents :: Int -> Int -> IO (MutableByteArray a)
409newAlignedArrayContents nbytes _align | nbytes < 0 =
409newAlignedArrayContents nbytes _align | nbytes < 0 =
410 errorWithoutStackTrace "newAlignedArrayContents: size must be >= 0"
410 errorWithoutStackTrace "newAlignedArrayContents: size must be >= 0"
411newAlignedArrayContents (I# nbytes) (I# align) = IO $ \s ->
411newAlignedArrayContents (I# nbytes) (I# align) = IO $ \s ->
412 case newAlignedPinnedByteArray# nbytes align s of
412 case newAlignedPinnedByteArray# nbytes align s of
413 (# s', mbarr# #) ->
413 (# s', mbarr# #) ->
414− let c = ArrayContents mbarr#
414+ let c = MutableByteArray mbarr#
415 in (# s', c #)
415 in (# s', c #)
416
416
417{-# NOINLINE nilArrayContents #-}
417{-# NOINLINE nilArrayContents #-}
418−nilArrayContents :: ArrayContents a
418+nilArrayContents :: MutableByteArray a
419nilArrayContents =
419nilArrayContents =
420 unsafePerformIO $ newAlignedArrayContents 0 0
420 unsafePerformIO $ newAlignedArrayContents 0 0
421
421
@@ -587,7 +587,7 @@ modify f Array{..} = liftIO $
587 go (INDEX_NEXT(i,a))
587 go (INDEX_NEXT(i,a))
588
588
589{-# INLINE swapArrayByteIndices #-}
589{-# INLINE swapArrayByteIndices #-}
590−swapArrayByteIndices :: Unboxed a => ArrayContents a -> Int -> Int -> IO ()
590+swapArrayByteIndices :: Unboxed a => MutableByteArray a -> Int -> Int -> IO ()
591swapArrayByteIndices arrContents i1 i2 = do
591swapArrayByteIndices arrContents i1 i2 = do
592 r1 <- peekWith arrContents i1
592 r1 <- peekWith arrContents i1
593 r2 <- peekWith arrContents i2
593 r2 <- peekWith arrContents i2
@@ -723,8 +723,8 @@ reallocAligned elemSize alignSize newCapacityInBytes Array{..} = do
723 -- Allocate new array
723 -- Allocate new array
724 let newCapMaxInBytes = roundUpLargeArray newCapacityInBytes
724 let newCapMaxInBytes = roundUpLargeArray newCapacityInBytes
725 contents <- newAlignedArrayContents newCapMaxInBytes alignSize
725 contents <- newAlignedArrayContents newCapMaxInBytes alignSize
726− let !(ArrayContents mbarrFrom#) = arrContents
726+ let !(MutableByteArray mbarrFrom#) = arrContents
727− !(ArrayContents mbarrTo#) = contents
727+ !(MutableByteArray mbarrTo#) = contents
728
728
729 -- Copy old data
729 -- Copy old data
730 let oldStart = arrStart
730 let oldStart = arrStart
@@ -1421,7 +1421,7 @@ flattenArraysRev (D.Stream step state) = D.Stream step' (OuterLoop state)
1421-------------------------------------------------------------------------------
1421-------------------------------------------------------------------------------
1422
1422
1423data ArrayUnsafe a = ArrayUnsafe
1423data ArrayUnsafe a = ArrayUnsafe
1424− {-# UNPACK #-} !(ArrayContents a) -- contents
1424+ {-# UNPACK #-} !(MutableByteArray a) -- contents
1425 {-# UNPACK #-} !Int -- index 1
1425 {-# UNPACK #-} !Int -- index 1
1426 {-# UNPACK #-} !Int -- index 2
1426 {-# UNPACK #-} !Int -- index 2
1427
1427
core/src/Streamly/Internal/Data/Array/Unboxed/Type.hs+2−2
@@ -85,7 +85,7 @@ import GHC.Exts (IsList, IsString(..))
85
85
86import GHC.IO (unsafePerformIO)
86import GHC.IO (unsafePerformIO)
87import GHC.Ptr (Ptr(..))
87import GHC.Ptr (Ptr(..))
88−import Streamly.Internal.Data.Array.Unboxed.Mut.Type (ArrayContents)
88+import Streamly.Internal.Data.Array.Unboxed.Mut.Type (MutableByteArray)
89import Streamly.Internal.Data.Fold.Type (Fold(..))
89import Streamly.Internal.Data.Fold.Type (Fold(..))
90import Streamly.Internal.Data.Stream.Type (Stream)
90import Streamly.Internal.Data.Stream.Type (Stream)
91import Streamly.Internal.Data.Unboxed (Unboxed, peekWith, sizeOf)
91import Streamly.Internal.Data.Unboxed (Unboxed, peekWith, sizeOf)
@@ -133,7 +133,7 @@ data Array a =
133#endif
133#endif
134 -- All offsets are in terms of bytes from the start of arraycontents
134 -- All offsets are in terms of bytes from the start of arraycontents
135 Array
135 Array
136− { arrContents :: {-# UNPACK #-} !(ArrayContents a)
136+ { arrContents :: {-# UNPACK #-} !(MutableByteArray a)
137 , arrStart :: {-# UNPACK #-} !Int -- offset
137 , arrStart :: {-# UNPACK #-} !Int -- offset
138 , arrEnd :: {-# UNPACK #-} !Int -- offset + len
138 , arrEnd :: {-# UNPACK #-} !Int -- offset + len
139 }
139 }
core/src/Streamly/Internal/Data/Fold.hs+3−3
@@ -306,7 +306,7 @@ import Data.IORef (newIORef, readIORef, writeIORef)
306import Data.Map.Strict (Map)
306import Data.Map.Strict (Map)
307import Data.Maybe (isJust, fromJust)
307import Data.Maybe (isJust, fromJust)
308import Data.Word (Word32)
308import Data.Word (Word32)
309−import Foreign.Storable (Storable, peek, sizeOf)
309+import Foreign.Storable (peek, sizeOf)
310import Streamly.Internal.Data.IsMap (IsMap(..))
310import Streamly.Internal.Data.IsMap (IsMap(..))
311import Streamly.Internal.Data.Pipe.Type (Pipe (..), PipeState(..))
311import Streamly.Internal.Data.Pipe.Type (Pipe (..), PipeState(..))
312import Streamly.Internal.Data.Unboxed (Unboxed)
312import Streamly.Internal.Data.Unboxed (Unboxed)
@@ -1483,7 +1483,7 @@ data SplitOnSeqState acc a rb rh w ck =
1483--
1483--
1484-- /Pre-release/
1484-- /Pre-release/
1485{-# INLINE takeEndBySeq #-}
1485{-# INLINE takeEndBySeq #-}
1486−takeEndBySeq :: forall m a b. (MonadIO m, Storable a, Unboxed a, Enum a, Eq a) =>
1486+takeEndBySeq :: forall m a b. (MonadIO m, Unboxed a, Enum a, Eq a) =>
1487 Array.Array a
1487 Array.Array a
1488 -> Fold m a b
1488 -> Fold m a b
1489 -> Fold m a b
1489 -> Fold m a b
@@ -1619,7 +1619,7 @@ takeEndBySeq patArr (Fold fstep finitial fextract) =
1619-- /Pre-release/
1619-- /Pre-release/
1620--
1620--
1621{-# INLINE takeEndBySeq_ #-}
1621{-# INLINE takeEndBySeq_ #-}
1622−takeEndBySeq_ :: forall m a b. (MonadIO m, Storable a, Unboxed a, Enum a, Eq a) =>
1622+takeEndBySeq_ :: forall m a b. (MonadIO m, Unboxed a, Enum a, Eq a) =>
1623 Array.Array a
1623 Array.Array a
1624 -> Fold m a b
1624 -> Fold m a b
1625 -> Fold m a b
1625 -> Fold m a b
core/src/Streamly/Internal/Data/IORef/Unboxed.hs+4−3
@@ -40,8 +40,9 @@ where
40
40
41import Control.Monad.IO.Class (MonadIO(..))
41import Control.Monad.IO.Class (MonadIO(..))
42import Streamly.Internal.Data.Unboxed
42import Streamly.Internal.Data.Unboxed
43− ( ArrayContents(..)
43+ ( MutableByteArray(..)
44− , Unboxed(..)
44+ , Unboxed
45+ , sizeOf
45 , peekWith
46 , peekWith
46 , pokeWith
47 , pokeWith
47 , newUnpinnedArrayContents
48 , newUnpinnedArrayContents
@@ -50,7 +51,7 @@ import Streamly.Internal.Data.Unboxed
50import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
51import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
51
52
52-- | An 'IORef' holds a single 'Unboxed' value.
53-- | An 'IORef' holds a single 'Unboxed' value.
53−newtype IORef a = IORef (ArrayContents a)
54+newtype IORef a = IORef (MutableByteArray a)
54
55
55-- | Create a new 'IORef'.
56-- | Create a new 'IORef'.
56--
57--
core/src/Streamly/Internal/Data/Ring/Foreign.hs+5−5
@@ -80,7 +80,7 @@ import Foreign.ForeignPtr (ForeignPtr, withForeignPtr, touchForeignPtr)
80import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
80import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
81import Foreign.Ptr (plusPtr, minusPtr, castPtr)
81import Foreign.Ptr (plusPtr, minusPtr, castPtr)
82import Streamly.Internal.Data.Unboxed as Unboxed
82import Streamly.Internal.Data.Unboxed as Unboxed
83− ( ArrayContents
83+ ( MutableByteArray
84 , Unboxed
84 , Unboxed
85 , castContents
85 , castContents
86 , peekWith
86 , peekWith
@@ -412,7 +412,7 @@ unsafeEqArrayN Ring{..} rh A.Array{..} nBytes
412
412
413 where
413 where
414
414
415− w8Contents = castContents arrContents :: ArrayContents Word8
415+ w8Contents = castContents arrContents :: MutableByteArray Word8
416
416
417 check p i = do
417 check p i = do
418 relem <- peek p
418 relem <- peek p
@@ -446,7 +446,7 @@ unsafeEqArray Ring{..} rh A.Array{..} =
446
446
447 where
447 where
448
448
449− w8Contents = castContents arrContents :: ArrayContents Word8
449+ w8Contents = castContents arrContents :: MutableByteArray Word8
450
450
451 check p i = do
451 check p i = do
452 relem <- peek p
452 relem <- peek p
@@ -561,7 +561,7 @@ data Tuple4' a b c d = Tuple4' !a !b !c !d deriving Show
561-- a))@ action depends on when it is executed. It does not capture the sanpshot
561-- a))@ action depends on when it is executed. It does not capture the sanpshot
562-- of the ring at a particular time.
562-- of the ring at a particular time.
563{-# INLINE slidingWindowWith #-}
563{-# INLINE slidingWindowWith #-}
564−slidingWindowWith :: forall m a b. (MonadIO m, Storable a, Unboxed a)
564+slidingWindowWith :: forall m a b. (MonadIO m, Unboxed a)
565 => Int -> Fold m ((a, Maybe a), m (Array a)) b -> Fold m a b
565 => Int -> Fold m ((a, Maybe a), m (Array a)) b -> Fold m a b
566slidingWindowWith n (Fold step1 initial1 extract1) = Fold step initial extract
566slidingWindowWith n (Fold step1 initial1 extract1) = Fold step initial extract
567
567
@@ -615,6 +615,6 @@ slidingWindowWith n (Fold step1 initial1 extract1) = Fold step initial extract
615-- there is no old element.
615-- there is no old element.
616--
616--
617{-# INLINE slidingWindow #-}
617{-# INLINE slidingWindow #-}
618−slidingWindow :: forall m a b. (MonadIO m, Storable a, Unboxed a)
618+slidingWindow :: forall m a b. (MonadIO m, Unboxed a)
619 => Int -> Fold m (a, Maybe a) b -> Fold m a b
619 => Int -> Fold m (a, Maybe a) b -> Fold m a b
620slidingWindow n f = slidingWindowWith n (lmap fst f)
620slidingWindow n f = slidingWindowWith n (lmap fst f)
core/src/Streamly/Internal/Data/Stream/Eliminate.hs+1−2
@@ -73,7 +73,6 @@ where
73import Control.Monad.Catch (MonadThrow)
73import Control.Monad.Catch (MonadThrow)
74import Control.Monad.IO.Class (MonadIO(..))
74import Control.Monad.IO.Class (MonadIO(..))
75import Control.Monad.Trans.Class (MonadTrans(..))
75import Control.Monad.Trans.Class (MonadTrans(..))
76−import Foreign.Storable (Storable)
77import Streamly.Internal.Data.Parser (Parser (..))
76import Streamly.Internal.Data.Parser (Parser (..))
78import Streamly.Internal.Data.Unboxed (Unboxed)
77import Streamly.Internal.Data.Unboxed (Unboxed)
79
78
@@ -284,7 +283,7 @@ isPrefixOf m1 m2 = D.isPrefixOf (toStreamD m1) (toStreamD m2)
284-- /Requires 'Storable' constraint/
283-- /Requires 'Storable' constraint/
285--
284--
286{-# INLINE isInfixOf #-}
285{-# INLINE isInfixOf #-}
287−isInfixOf :: (MonadIO m, Eq a, Enum a, Unboxed a, Storable a)
286+isInfixOf :: (MonadIO m, Eq a, Enum a, Unboxed a)
288 => Stream m a -> Stream m a -> m Bool
287 => Stream m a -> Stream m a -> m Bool
289isInfixOf infx stream = do
288isInfixOf infx stream = do
290 arr <- fold Array.write infx
289 arr <- fold Array.write infx
core/src/Streamly/Internal/Data/Stream/StreamD/Nesting.hs+3−3
@@ -155,7 +155,7 @@ import Control.Monad.IO.Class (MonadIO(..))
155import Data.Bits (shiftR, shiftL, (.|.), (.&.))
155import Data.Bits (shiftR, shiftL, (.|.), (.&.))
156import Data.Functor.Identity ( Identity )
156import Data.Functor.Identity ( Identity )
157import Data.Word (Word32)
157import Data.Word (Word32)
158−import Foreign.Storable (Storable, peek, sizeOf)
158+import Foreign.Storable (peek, sizeOf)
159import Fusion.Plugin.Types (Fuse(..))
159import Fusion.Plugin.Types (Fuse(..))
160import GHC.Types (SPEC(..))
160import GHC.Types (SPEC(..))
161
161
@@ -1823,7 +1823,7 @@ data SplitOnSeqState rb rh ck w fs s b x =
1823
1823
1824{-# INLINE_NORMAL splitOnSeq #-}
1824{-# INLINE_NORMAL splitOnSeq #-}
1825splitOnSeq
1825splitOnSeq
1826− :: forall m a b. (MonadIO m, Storable a, Unboxed a, Enum a, Eq a)
1826+ :: forall m a b. (MonadIO m, Unboxed a, Enum a, Eq a)
1827 => Array a
1827 => Array a
1828 -> Fold m a b
1828 -> Fold m a b
1829 -> Stream m a
1829 -> Stream m a
@@ -2136,7 +2136,7 @@ data SplitOnSuffixSeqState rb rh ck w fs s b x =
2136
2136
2137{-# INLINE_NORMAL splitOnSuffixSeq #-}
2137{-# INLINE_NORMAL splitOnSuffixSeq #-}
2138splitOnSuffixSeq
2138splitOnSuffixSeq
2139− :: forall m a b. (MonadIO m, Storable a, Unboxed a, Enum a, Eq a)
2139+ :: forall m a b. (MonadIO m, Unboxed a, Enum a, Eq a)
2140 => Bool
2140 => Bool
2141 -> Array a
2141 -> Array a
2142 -> Fold m a b
2142 -> Fold m a b
core/src/Streamly/Internal/Data/Time/Units.hs+8−4
@@ -51,7 +51,8 @@ where
51import Text.Printf (printf)
51import Text.Printf (printf)
52
52
53import Data.Int
53import Data.Int
54+import Foreign.Storable (Storable)
54−import Streamly.Internal.Data.Unboxed (Unboxed)
55+import Streamly.Internal.Data.Unboxed (Unbox)
55import Streamly.Internal.Data.Time.TimeSpec
56import Streamly.Internal.Data.Time.TimeSpec
56
57
57-------------------------------------------------------------------------------
58-------------------------------------------------------------------------------
@@ -106,7 +107,8 @@ newtype NanoSecond64 = NanoSecond64 Int64
106 , Real
107 , Real
107 , Integral
108 , Integral
108 , Ord
109 , Ord
109− , Unboxed
110+ , Storable
111+ , Unbox
110 )
112 )
111
113
112-- | An 'Int64' time representation with a microsecond resolution.
114-- | An 'Int64' time representation with a microsecond resolution.
@@ -121,7 +123,8 @@ newtype MicroSecond64 = MicroSecond64 Int64
121 , Real
123 , Real
122 , Integral
124 , Integral
123 , Ord
125 , Ord
124− , Unboxed
126+ , Storable
127+ , Unbox
125 )
128 )
126
129
127-- | An 'Int64' time representation with a millisecond resolution.
130-- | An 'Int64' time representation with a millisecond resolution.
@@ -136,7 +139,8 @@ newtype MilliSecond64 = MilliSecond64 Int64
136 , Real
139 , Real
137 , Integral
140 , Integral
138 , Ord
141 , Ord
139− , Unboxed
142+ , Storable
143+ , Unbox
140 )
144 )
141
145
142-------------------------------------------------------------------------------
146-------------------------------------------------------------------------------
core/src/Streamly/Internal/Data/Unboxed.hs+78−102
@@ -3,11 +3,12 @@
3
3
4module Streamly.Internal.Data.Unboxed
4module Streamly.Internal.Data.Unboxed
5 ( Unboxed
5 ( Unboxed
6+ , Unbox(..)
6 , alignment
7 , alignment
7 , peekWith
8 , peekWith
8 , pokeWith
9 , pokeWith
9 , sizeOf
10 , sizeOf
10− , ArrayContents(..)
11+ , MutableByteArray(..)
11 , castContents
12 , castContents
12 , touch
13 , touch
13 , getMutableByteArray#
14 , getMutableByteArray#
@@ -20,10 +21,11 @@ module Streamly.Internal.Data.Unboxed
20
21
21#include "ArrayMacros.h"
22#include "ArrayMacros.h"
22
23
23−import Data.Complex (Complex((:+)), realPart)
24+import Data.Complex (Complex((:+)))
24import GHC.Base (IO(..))
25import GHC.Base (IO(..))
25import GHC.Int (Int32(..), Int64(..))
26import GHC.Int (Int32(..), Int64(..))
26import GHC.Word (Word8(..), Word64(..))
27import GHC.Word (Word8(..), Word64(..))
28+import Foreign.Storable (Storable(..))
27
29
28import GHC.Exts
30import GHC.Exts
29
31
@@ -32,19 +34,19 @@ import GHC.Exts
32--------------------------------------------------------------------------------
34--------------------------------------------------------------------------------
33
35
34-- XXX can use UnliftedNewtypes
36-- XXX can use UnliftedNewtypes
35−data ArrayContents a = ArrayContents !(MutableByteArray# RealWorld)
37+data MutableByteArray a = MutableByteArray !(MutableByteArray# RealWorld)
36
38
37{-# INLINE getMutableByteArray# #-}
39{-# INLINE getMutableByteArray# #-}
38−getMutableByteArray# :: ArrayContents a -> MutableByteArray# RealWorld
40+getMutableByteArray# :: MutableByteArray a -> MutableByteArray# RealWorld
39−getMutableByteArray# (ArrayContents mbarr) = mbarr
41+getMutableByteArray# (MutableByteArray mbarr) = mbarr
40
42
41{-# INLINE castContents #-}
43{-# INLINE castContents #-}
42−castContents :: ArrayContents a -> ArrayContents b
44+castContents :: MutableByteArray a -> MutableByteArray b
43−castContents (ArrayContents mbarr) = ArrayContents mbarr
45+castContents (MutableByteArray mbarr) = MutableByteArray mbarr
44
46
45{-# INLINE touch #-}
47{-# INLINE touch #-}
46−touch :: ArrayContents a -> IO ()
48+touch :: MutableByteArray a -> IO ()
47−touch (ArrayContents contents) =
49+touch (MutableByteArray contents) =
48 IO $ \s -> case touch# contents s of s' -> (# s', () #)
50 IO $ \s -> case touch# contents s of s' -> (# s', () #)
49
51
50--------------------------------------------------------------------------------
52--------------------------------------------------------------------------------
@@ -52,13 +54,13 @@ touch (ArrayContents contents) =
52--------------------------------------------------------------------------------
54--------------------------------------------------------------------------------
53
55
54{-# INLINE newUnpinnedArrayContents #-}
56{-# INLINE newUnpinnedArrayContents #-}
55−newUnpinnedArrayContents :: Int -> IO (ArrayContents a)
57+newUnpinnedArrayContents :: Int -> IO (MutableByteArray a)
56newUnpinnedArrayContents nbytes | nbytes < 0 =
58newUnpinnedArrayContents nbytes | nbytes < 0 =
57 errorWithoutStackTrace "newUnpinnedArrayContents: size must be >= 0"
59 errorWithoutStackTrace "newUnpinnedArrayContents: size must be >= 0"
58newUnpinnedArrayContents (I# nbytes) = IO $ \s ->
60newUnpinnedArrayContents (I# nbytes) = IO $ \s ->
59 case newByteArray# nbytes s of
61 case newByteArray# nbytes s of
60 (# s', mbarr# #) ->
62 (# s', mbarr# #) ->
61− let c = ArrayContents mbarr#
63+ let c = MutableByteArray mbarr#
62 in (# s', c #)
64 in (# s', c #)
63
65
64-------------------------------------------------------------------------------
66-------------------------------------------------------------------------------
@@ -66,8 +68,8 @@ newUnpinnedArrayContents (I# nbytes) = IO $ \s ->
66-------------------------------------------------------------------------------
68-------------------------------------------------------------------------------
67
69
68{-# INLINE isPinned #-}
70{-# INLINE isPinned #-}
69−isPinned :: ArrayContents a -> Bool
71+isPinned :: MutableByteArray a -> Bool
70−isPinned (ArrayContents arr#) =
72+isPinned (MutableByteArray arr#) =
71 let pinnedInt = I# (isMutableByteArrayPinned# arr#)
73 let pinnedInt = I# (isMutableByteArrayPinned# arr#)
72 in pinnedInt == 1
74 in pinnedInt == 1
73
75
@@ -88,24 +90,24 @@ cloneMutableArrayWith# alloc# arr# s# =
88 s3# -> (# s3#, arr1# #)
90 s3# -> (# s3#, arr1# #)
89
91
90{-# INLINE pin #-}
92{-# INLINE pin #-}
91−pin :: ArrayContents a -> IO (ArrayContents a)
93+pin :: MutableByteArray a -> IO (MutableByteArray a)
92−pin arr@(ArrayContents marr#) =
94+pin arr@(MutableByteArray marr#) =
93 if isPinned arr
95 if isPinned arr
94 then return arr
96 then return arr
95 else IO
97 else IO
96 $ \s# ->
98 $ \s# ->
97 case cloneMutableArrayWith# newPinnedByteArray# marr# s# of
99 case cloneMutableArrayWith# newPinnedByteArray# marr# s# of
98− (# s1#, marr1# #) -> (# s1#, ArrayContents marr1# #)
100+ (# s1#, marr1# #) -> (# s1#, MutableByteArray marr1# #)
99
101
100{-# INLINE unpin #-}
102{-# INLINE unpin #-}
101−unpin :: ArrayContents a -> IO (ArrayContents a)
103+unpin :: MutableByteArray a -> IO (MutableByteArray a)
102−unpin arr@(ArrayContents marr#) =
104+unpin arr@(MutableByteArray marr#) =
103 if not (isPinned arr)
105 if not (isPinned arr)
104 then return arr
106 then return arr
105 else IO
107 else IO
106 $ \s# ->
108 $ \s# ->
107 case cloneMutableArrayWith# newByteArray# marr# s# of
109 case cloneMutableArrayWith# newByteArray# marr# s# of
108− (# s1#, marr1# #) -> (# s1#, ArrayContents marr1# #)
110+ (# s1#, marr1# #) -> (# s1#, MutableByteArray marr1# #)
109
111
110--------------------------------------------------------------------------------
112--------------------------------------------------------------------------------
111-- The Unboxed type class
113-- The Unboxed type class
@@ -225,14 +227,16 @@ writeWord8ArrayAsDouble# arr# i# =
225-- class allows each primitive type to have its own specific efficient
227-- class allows each primitive type to have its own specific efficient
226-- implementation to read and write the type to memory.
228-- implementation to read and write the type to memory.
227--
229--
228−-- The ArrayContents type currently uses a MutableByteArray#. However, we could
230+-- This is a typeclass that uses MutableByteArray but could use ForeignPtr or
229−-- also use a foreign ptr instead. That would just make the implementation a
231+-- any other representation of memory. We could make this a multiparameter type
232+-- class if necessary.
233+--
230−-- bit more complicated. In that case the type class would have to support
234+-- If the type class would have to support reading and writing to a Ptr as well,
231−-- reading and writing to a Ptr as well, basically what Storable does. We will
232−-- also need to touch the anchoring ptr at the right points which is prone to
235+-- basically what Storable does. We will also need to touch the anchoring ptr at
236+-- the right points which is prone to errors. However, it should be simple to
233−-- errors. However, it should be simple to implement unmanaged/read-only memory
237+-- implement unmanaged/read-only memory arrays by allowing a Ptr type in
234−-- arrays by allowing a Ptr type in ArrayContents, though it would require all
235−-- instances to support reading from a Ptr.
238+-- ArrayContents, though it would require all instances to support reading from
239+-- a Ptr.
236--
240--
237-- There is a reason for using byte offset instead of element index in read and
241-- There is a reason for using byte offset instead of element index in read and
238-- write operations in the type class. If we use element index slicing of the
242-- write operations in the type class. If we use element index slicing of the
@@ -245,144 +249,116 @@ writeWord8ArrayAsDouble# arr# i# =
245-- anymore, see
249-- anymore, see
246-- https://lemire.me/blog/2012/05/31/data-alignment-for-speed-myth-or-reality/
250-- https://lemire.me/blog/2012/05/31/data-alignment-for-speed-myth-or-reality/
247--
251--
248−-- We try to keep the instances compatible with Storable. But we may have to
252+-- We have to keep the instances compatible with Storable as we depend on it for
249−-- differ, for example a Bool instance can be implemented more efficiently
250−-- using a bit vector. Need to check the performance. We can possibly write
251−-- tests for checking compatibility with Storable.
253+-- size and alignment. We can possibly write tests for checking compatibility
254+-- with Storable.
252
255
253−-- | An 'Unboxed' type supplies operations for reading and writing the type
256+-- | An 'Unbox' type supplies operations for reading and writing the type
254-- from and to a byte array in memory. The read operation constructs the boxed
257-- from and to a byte array in memory. The read operation constructs the boxed
255-- type from an unboxed byte representation in memory. The write operation
258-- type from an unboxed byte representation in memory. The write operation
256-- writes the boxed type to an unboxed byte representation in memory.
259-- writes the boxed type to an unboxed byte representation in memory.
257--
260--
261+-- This type class dependes on Storable for size and alignment of the type. It
262+-- is similar to Storable in the sense that it has corresponding operations for
258−-- This type class is similar to Storable. While Storable allows writing to a
263+-- peekByteOff and pokeByteOff. While Storable allows writing to a Ptr, this
259−-- Ptr, this type class allows writing to a MutableByteArray#.
264+-- type class allows writing to a MutableByteArray#.
260−class Unboxed a where
265+class Storable a => Unbox a where
261− sizeOf :: a -> Int
262− alignment :: a -> Int
263−
264− -- Read an element of type "a" from a MutableByteArray given the byte
266+ -- | Read an element of type "a" from a MutableByteArray given the byte
265 -- index.
267 -- index.
266− readByteArray :: ArrayContents a -> Int -> IO a
268+ box :: MutableByteArray a -> Int -> IO a
267− writeByteArray :: ArrayContents a -> Int -> a -> IO ()
269+ -- | Write an element of type "a" to a MutableByteArray given the byte
268−
270+ -- index.
271+ unbox :: MutableByteArray a -> Int -> a -> IO ()
272+
273+type Unboxed a = (Unbox a, Storable a)
274+
269−#define DERIVE_UNBOXED(_type, _constructor, _sizeOf, _alignment, _readArray, _writeArray) \
275+#define DERIVE_UNBOXED(_type, _constructor, _readArray, _writeArray) \
270−instance Unboxed _type where { \
276+instance Unbox _type where { \
271−; {-# INLINE sizeOf #-} \
277+; {-# INLINE box #-} \
272−; sizeOf _ = _sizeOf \
278+; box (MutableByteArray mbarr) (I# n) = IO $ \s -> \
273−; {-# INLINE alignment #-} \
274−; alignment _ = _alignment \
275−; {-# INLINE readByteArray #-} \
276−; readByteArray (ArrayContents mbarr) (I# n) = IO $ \s -> \
277 case _readArray mbarr n s of \
279 case _readArray mbarr n s of \
278 { (# s1, i #) -> (# s1, _constructor i #) } \
280 { (# s1, i #) -> (# s1, _constructor i #) } \
279−; {-# INLINE writeByteArray #-} \
281+; {-# INLINE unbox #-} \
280−; writeByteArray (ArrayContents mbarr) (I# n) (_constructor val) = \
282+; unbox (MutableByteArray mbarr) (I# n) (_constructor val) = \
281 IO $ \s -> (# _writeArray mbarr n val s, () #) \
283 IO $ \s -> (# _writeArray mbarr n val s, () #) \
282}
284}
283
285
284DERIVE_UNBOXED( Char
286DERIVE_UNBOXED( Char
285 , C#
287 , C#
286− , SIZEOF_HSCHAR
287− , ALIGNMENT_HSCHAR
288 , readWord8ArrayAsWideChar#
288 , readWord8ArrayAsWideChar#
289 , writeWord8ArrayAsWideChar#)
289 , writeWord8ArrayAsWideChar#)
290
290
291DERIVE_UNBOXED( Int32
291DERIVE_UNBOXED( Int32
292 , I32#
292 , I32#
293− , SIZEOF_INT32
294− , ALIGNMENT_INT32
295 , readWord8ArrayAsInt32#
293 , readWord8ArrayAsInt32#
296 , writeWord8ArrayAsInt32#)
294 , writeWord8ArrayAsInt32#)
297
295
298DERIVE_UNBOXED( Int
296DERIVE_UNBOXED( Int
299 , I#
297 , I#
300− , SIZEOF_HSINT
301− , ALIGNMENT_HSINT
302 , readWord8ArrayAsInt#
298 , readWord8ArrayAsInt#
303 , writeWord8ArrayAsInt#)
299 , writeWord8ArrayAsInt#)
304
300
305DERIVE_UNBOXED( Int64
301DERIVE_UNBOXED( Int64
306 , I64#
302 , I64#
307− , SIZEOF_INT64
308− , ALIGNMENT_INT64
309 , readWord8ArrayAsInt64#
303 , readWord8ArrayAsInt64#
310 , writeWord8ArrayAsInt64#)
304 , writeWord8ArrayAsInt64#)
311
305
312DERIVE_UNBOXED( Word
306DERIVE_UNBOXED( Word
313 , W#
307 , W#
314− , SIZEOF_HSWORD
315− , ALIGNMENT_HSWORD
316 , readWord8ArrayAsWord#
308 , readWord8ArrayAsWord#
317 , writeWord8ArrayAsWord#)
309 , writeWord8ArrayAsWord#)
318
310
319DERIVE_UNBOXED( Word8
311DERIVE_UNBOXED( Word8
320 , W8#
312 , W8#
321− , SIZEOF_WORD8
322− , ALIGNMENT_WORD8
323 , readWord8Array#
313 , readWord8Array#
324 , writeWord8Array#)
314 , writeWord8Array#)
325
315
326DERIVE_UNBOXED( Word64
316DERIVE_UNBOXED( Word64
327 , W64#
317 , W64#
328− , SIZEOF_WORD64
329− , ALIGNMENT_WORD64
330 , readWord8ArrayAsWord64#
318 , readWord8ArrayAsWord64#
331 , writeWord8ArrayAsWord64#)
319 , writeWord8ArrayAsWord64#)
332
320
333DERIVE_UNBOXED( Double
321DERIVE_UNBOXED( Double
334 , D#
322 , D#
335− , SIZEOF_DOUBLE
336− , ALIGNMENT_DOUBLE
337 , readWord8ArrayAsDouble#
323 , readWord8ArrayAsDouble#
338 , writeWord8ArrayAsDouble#)
324 , writeWord8ArrayAsDouble#)
339
325
340−instance Unboxed Bool where
326+instance Unbox Bool where
341− {-# INLINE sizeOf #-}
342− sizeOf _ = sizeOf (undefined :: Word8)
343−
344− {-# INLINE alignment #-}
345− alignment _ = alignment (undefined :: Word8)
346
327
347− {-# INLINE readByteArray #-}
328+ {-# INLINE box #-}
348− readByteArray arr i = do
329+ box arr i = do
349− res <- readByteArray (castContents arr) i
330+ res <- box (castContents arr) i
350− return $ res /= (0 :: Word8)
331+ return $ res /= (0 :: Int32)
351
332
352− {-# INLINE writeByteArray #-}
333+ {-# INLINE unbox #-}
353− writeByteArray arr i a =
334+ unbox arr i a =
354 if a
335 if a
355− then writeByteArray (castContents arr) i (1 :: Word8)
336+ then unbox (castContents arr) i (1 :: Int32)
356− else writeByteArray (castContents arr) i (0 :: Word8)
337+ else unbox (castContents arr) i (0 :: Int32)
357−
358−instance forall a. Unboxed a => Unboxed (Complex a) where
359− {-# INLINE sizeOf #-}
360− sizeOf a = 2 * sizeOf (realPart a)
361
338
362− {-# INLINE alignment #-}
339+instance forall a. Unboxed a => Unbox (Complex a) where
363− alignment a = alignment (realPart a)
364
340
365− {-# INLINE readByteArray #-}
341+ {-# INLINE box #-}
366− readByteArray arr i = do
342+ box arr i = do
367− let contents = castContents arr :: ArrayContents a
343+ let contents = castContents arr :: MutableByteArray a
368− real <- readByteArray contents i
344+ real <- box contents i
369− img <- readByteArray contents (i + SIZE_OF(a))
345+ img <- box contents (i + SIZE_OF(a))
370 return $ real :+ img
346 return $ real :+ img
371
347
372− {-# INLINE writeByteArray #-}
348+ {-# INLINE unbox #-}
373− writeByteArray arr i (real :+ img) = do
349+ unbox arr i (real :+ img) = do
374− let contents = castContents arr :: ArrayContents a
350+ let contents = castContents arr :: MutableByteArray a
375− writeByteArray contents i real
351+ unbox contents i real
376− writeByteArray contents (i + SIZE_OF(a)) img
352+ unbox contents (i + SIZE_OF(a)) img
377
353
378--------------------------------------------------------------------------------
354--------------------------------------------------------------------------------
379-- Functions
355-- Functions
380--------------------------------------------------------------------------------
356--------------------------------------------------------------------------------
381
357
382{-# INLINE peekWith #-}
358{-# INLINE peekWith #-}
383−peekWith :: Unboxed a => ArrayContents a -> Int -> IO a
359+peekWith :: Unboxed a => MutableByteArray a -> Int -> IO a
384−peekWith = readByteArray
360+peekWith = box
385
361
386{-# INLINE pokeWith #-}
362{-# INLINE pokeWith #-}
387−pokeWith :: Unboxed a => ArrayContents a -> Int -> a -> IO ()
363+pokeWith :: Unboxed a => MutableByteArray a -> Int -> a -> IO ()
388−pokeWith = writeByteArray
364+pokeWith = unbox
src/Streamly/Internal/Data/Array/Stream/Foreign.hs+1−1
@@ -170,7 +170,7 @@ interposeSuffix x = S.interposeSuffix x A.read
170
170
171data FlattenState s a =
171data FlattenState s a =
172 OuterLoop s
172 OuterLoop s
173− | InnerLoop s !(MA.ArrayContents a) !Int !Int
173+ | InnerLoop s !(MA.MutableByteArray a) !Int !Int
174
174
175-- XXX Remove monadIO constraint
175-- XXX Remove monadIO constraint
176{-# INLINE_NORMAL unlines #-}
176{-# INLINE_NORMAL unlines #-}
src/Streamly/Internal/Data/Stream/IsStream/Common.hs+1−2
@@ -69,7 +69,6 @@ where
69
69
70import Control.Concurrent (threadDelay)
70import Control.Concurrent (threadDelay)
71import Control.Monad.IO.Class (MonadIO(..))
71import Control.Monad.IO.Class (MonadIO(..))
72−import qualified Foreign.Storable as Storable (Storable)
73import Streamly.Internal.Control.Concurrent (MonadAsync)
72import Streamly.Internal.Control.Concurrent (MonadAsync)
74import Streamly.Internal.Data.Array.Unboxed.Type (Array)
73import Streamly.Internal.Data.Array.Unboxed.Type (Array)
75import Streamly.Internal.Data.Fold.Type (Fold (..))
74import Streamly.Internal.Data.Fold.Type (Fold (..))
@@ -673,7 +672,7 @@ foldManyPost f m = fromStreamD $ D.foldManyPost f (toStreamD m)
673-- that we can search files in files for example.
672-- that we can search files in files for example.
674{-# INLINE splitOnSeq #-}
673{-# INLINE splitOnSeq #-}
675splitOnSeq
674splitOnSeq
676− :: (IsStream t, MonadIO m, Storable.Storable a, Unboxed a, Enum a, Eq a)
675+ :: (IsStream t, MonadIO m, Unboxed a, Enum a, Eq a)
677 => Array a -> Fold m a b -> t m a -> t m b
676 => Array a -> Fold m a b -> t m a -> t m b
678splitOnSeq patt f m =
677splitOnSeq patt f m =
679 IsStream.fromStreamD $ D.splitOnSeq patt f (IsStream.toStreamD m)
678 IsStream.fromStreamD $ D.splitOnSeq patt f (IsStream.toStreamD m)
src/Streamly/Internal/Data/Stream/IsStream/Eliminate.hs+1−2
@@ -156,7 +156,6 @@ where
156
156
157import Control.Monad.IO.Class (MonadIO(..))
157import Control.Monad.IO.Class (MonadIO(..))
158import Control.Monad.Trans.Class (MonadTrans(..))
158import Control.Monad.Trans.Class (MonadTrans(..))
159−import qualified Foreign.Storable as Storable (Storable)
160import Streamly.Internal.Control.Concurrent (MonadAsync)
159import Streamly.Internal.Control.Concurrent (MonadAsync)
161import Streamly.Internal.Data.SVar (defState)
160import Streamly.Internal.Data.SVar (defState)
162import Streamly.Internal.Data.Stream.IsStream.Common
161import Streamly.Internal.Data.Stream.IsStream.Common
@@ -841,7 +840,7 @@ isPrefixOf m1 m2 = D.isPrefixOf (toStreamD m1) (toStreamD m2)
841-- /Requires 'Storable' constraint/
840-- /Requires 'Storable' constraint/
842--
841--
843{-# INLINE isInfixOf #-}
842{-# INLINE isInfixOf #-}
844−isInfixOf :: (MonadIO m, Eq a, Enum a, Storable.Storable a, Unboxed a)
843+isInfixOf :: (MonadIO m, Eq a, Enum a, Unboxed a)
845 => SerialT m a -> SerialT m a -> m Bool
844 => SerialT m a -> SerialT m a -> m Bool
846isInfixOf infx stream = do
845isInfixOf infx stream = do
847 arr <- fold A.write infx
846 arr <- fold A.write infx
src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+3−4
@@ -157,7 +157,6 @@ import Data.Kind (Type)
157import Data.Map (Map)
157import Data.Map (Map)
158import Data.Maybe (isNothing)
158import Data.Maybe (isNothing)
159import Data.Proxy (Proxy(..))
159import Data.Proxy (Proxy(..))
160−import qualified Foreign.Storable as Storable (Storable)
161import Streamly.Internal.Control.Concurrent (MonadAsync)
160import Streamly.Internal.Control.Concurrent (MonadAsync)
162import Streamly.Internal.Data.Fold.Type (Fold (..))
161import Streamly.Internal.Data.Fold.Type (Fold (..))
163import Streamly.Internal.Data.IsMap (IsMap(..))
162import Streamly.Internal.Data.IsMap (IsMap(..))
@@ -824,7 +823,7 @@ splitOnAny _subseq _f _m =
824-- /Pre-release/
823-- /Pre-release/
825{-# INLINE splitBySeq #-}
824{-# INLINE splitBySeq #-}
826splitBySeq
825splitBySeq
827− :: (IsStream t, MonadAsync m, Storable.Storable a, Unboxed a, Enum a, Eq a)
826+ :: (IsStream t, MonadAsync m, Unboxed a, Enum a, Eq a)
828 => Array a -> Fold m a b -> t m a -> t m b
827 => Array a -> Fold m a b -> t m a -> t m b
829splitBySeq patt f m =
828splitBySeq patt f m =
830 intersperseM (fold f (A.toStream patt)) $ splitOnSeq patt f m
829 intersperseM (fold f (A.toStream patt)) $ splitOnSeq patt f m
@@ -875,7 +874,7 @@ splitBySeq patt f m =
875-- /Pre-release/
874-- /Pre-release/
876{-# INLINE splitOnSuffixSeq #-}
875{-# INLINE splitOnSuffixSeq #-}
877splitOnSuffixSeq
876splitOnSuffixSeq
878− :: (IsStream t, MonadIO m, Storable.Storable a, Unboxed a, Enum a, Eq a)
877+ :: (IsStream t, MonadIO m, Unboxed a, Enum a, Eq a)
879 => Array a -> Fold m a b -> t m a -> t m b
878 => Array a -> Fold m a b -> t m a -> t m b
880splitOnSuffixSeq patt f m =
879splitOnSuffixSeq patt f m =
881 fromStreamD $ D.splitOnSuffixSeq False patt f (toStreamD m)
880 fromStreamD $ D.splitOnSuffixSeq False patt f (toStreamD m)
@@ -927,7 +926,7 @@ wordsOn _subseq _f _m =
927-- /Pre-release/
926-- /Pre-release/
928{-# INLINE splitWithSuffixSeq #-}
927{-# INLINE splitWithSuffixSeq #-}
929splitWithSuffixSeq
928splitWithSuffixSeq
930− :: (IsStream t, MonadIO m, Storable.Storable a, Unboxed a, Enum a, Eq a)
929+ :: (IsStream t, MonadIO m, Unboxed a, Enum a, Eq a)
931 => Array a -> Fold m a b -> t m a -> t m b
930 => Array a -> Fold m a b -> t m a -> t m b
932splitWithSuffixSeq patt f m =
931splitWithSuffixSeq patt f m =
933 fromStreamD $ D.splitOnSuffixSeq True patt f (toStreamD m)
932 fromStreamD $ D.splitOnSuffixSeq True patt f (toStreamD m)
src/Streamly/Internal/Unicode/Stream.hs+4−4
@@ -102,7 +102,7 @@ import GHC.IO.Encoding.Failure (isSurrogate)
102import GHC.Ptr (Ptr (..), plusPtr)
102import GHC.Ptr (Ptr (..), plusPtr)
103import System.IO.Unsafe (unsafePerformIO)
103import System.IO.Unsafe (unsafePerformIO)
104import Streamly.Internal.Data.Array.Unboxed (Array)
104import Streamly.Internal.Data.Array.Unboxed (Array)
105−import Streamly.Internal.Data.Array.Unboxed.Mut.Type (ArrayContents)
105+import Streamly.Internal.Data.Array.Unboxed.Mut.Type (MutableByteArray)
106import Streamly.Internal.Data.Fold (Fold)
106import Streamly.Internal.Data.Fold (Fold)
107import Streamly.Internal.Data.Stream.IsStream.Type
107import Streamly.Internal.Data.Stream.IsStream.Type
108 (IsStream, fromStreamD, toStreamD, adapt)
108 (IsStream, fromStreamD, toStreamD, adapt)
@@ -703,9 +703,9 @@ decodeUtf8Lax = decodeUtf8
703#endif
703#endif
704data FlattenState s a
704data FlattenState s a
705 = OuterLoop s !(Maybe (DecodeState, CodePoint))
705 = OuterLoop s !(Maybe (DecodeState, CodePoint))
706− | InnerLoopDecodeInit s (ArrayContents a) !Int !Int
706+ | InnerLoopDecodeInit s (MutableByteArray a) !Int !Int
707− | InnerLoopDecodeFirst s (ArrayContents a) !Int !Int Word8
707+ | InnerLoopDecodeFirst s (MutableByteArray a) !Int !Int Word8
708− | InnerLoopDecoding s (ArrayContents a) !Int !Int
708+ | InnerLoopDecoding s (MutableByteArray a) !Int !Int
709 !DecodeState !CodePoint
709 !DecodeState !CodePoint
710 | YAndC !Char (FlattenState s a) -- These constructors can be
710 | YAndC !Char (FlattenState s a) -- These constructors can be
711 -- encoded in the UTF8DecodeState
711 -- encoded in the UTF8DecodeState
test/Streamly/Test/Prelude/Serial.hs+1−2
@@ -21,7 +21,6 @@ import Data.Word (Word8)
21import Data.Semigroup ((<>))
21import Data.Semigroup ((<>))
22#endif
22#endif
23import Data.Semigroup (Sum(..), getSum)
23import Data.Semigroup (Sum(..), getSum)
24−import Foreign.Storable (Storable)
25import Streamly.Internal.Data.Unboxed (Unboxed)
24import Streamly.Internal.Data.Unboxed (Unboxed)
26import Test.Hspec.QuickCheck
25import Test.Hspec.QuickCheck
27import Test.QuickCheck
26import Test.QuickCheck
@@ -113,7 +112,7 @@ splitOnSuffixSeq = do
113 $ IS.splitOnSuffixSeq (A.fromList pat) FL.toList (S.fromList xs)
112 $ IS.splitOnSuffixSeq (A.fromList pat) FL.toList (S.fromList xs)
114
113
115splitterProperties ::
114splitterProperties ::
116− forall a. (Arbitrary a, Eq a, Show a, Storable a, Unboxed a, Enum a)
115+ forall a. (Arbitrary a, Eq a, Show a, Unboxed a, Enum a)
117 => a
116 => a
118 -> String
117 -> String
119 -> Spec
118 -> Spec