on master help sign in
Merge pull request #1696 from composewell/Rename_Storable_constraint_Unboxed

Rename Storable constraint to Prim

commitd2aaef000435bf6769aee81ab0c916fdf655b3cc authorHarendra Kumar <harendra@composewell.com> dateSat 6 Aug 2022, 16:27 (4 years ago) parentaac1526df56bd6
17 files changed+287−291
benchmark/Streamly/Benchmark/Data/Array/Stream/Foreign.hs+3−3 benchmark/Streamly/Benchmark/Unicode/Stream.hs+2−2 core/src/Streamly/Internal/Data/Array/Stream/Fold/Foreign.hs+5−5 core/src/Streamly/Internal/Data/Array/Stream/Mut/Foreign.hs+10−10 core/src/Streamly/Internal/Data/Array/Unboxed.hs+21−22 core/src/Streamly/Internal/Data/Array/Unboxed/Mut.hs+6−6 core/src/Streamly/Internal/Data/Array/Unboxed/Mut/Type.hs+106−106 core/src/Streamly/Internal/Data/Array/Unboxed/Type.hs+47−47 core/src/Streamly/Internal/Data/Stream/Bottom.hs+2−2 core/src/Streamly/Internal/Data/Stream/Reduce.hs+2−2 core/src/Streamly/Internal/Data/Unboxed.hs+1−4 src/Streamly/Internal/Data/Array/Stream/Foreign.hs+32−32 src/Streamly/Internal/Data/Stream/IsStream/Common.hs+2−2 src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+7−7 src/Streamly/Internal/FileSystem/FD.hs+15−15 src/Streamly/Internal/FileSystem/Handle.hs+15−15 src/Streamly/Internal/Network/Socket.hs+11−11
benchmark/Streamly/Benchmark/Data/Array/Stream/Foreign.hs+3−3
@@ -48,7 +48,7 @@ import Streamly.Benchmark.Common
4848import Streamly.Benchmark.Common.Handle
4949
5050#ifdef INSPECTION
51−import Streamly.Internal.Data.Unboxed (Storable)
51+import Streamly.Internal.Data.Unboxed (Unboxed)
5252import Streamly.Internal.Data.Stream.StreamD.Type (Step(..))
5353import Test.Inspection
5454#endif
@@ -185,7 +185,7 @@ copyChunksSplitInterposeSuffix inh outh =
185185 $ Handle.getChunks inh
186186
187187#ifdef INSPECTION
188−inspect $ hasNoTypeClassesExcept 'copyChunksSplitInterposeSuffix [''Storable]
188+inspect $ hasNoTypeClassesExcept 'copyChunksSplitInterposeSuffix [''Unboxed]
189189inspect $ 'copyChunksSplitInterposeSuffix `hasNoType` ''Step
190190#endif
191191
@@ -200,7 +200,7 @@ copyChunksSplitInterpose inh outh =
200200 $ Handle.getChunks inh
201201
202202#ifdef INSPECTION
203−inspect $ hasNoTypeClassesExcept 'copyChunksSplitInterpose [''Storable]
203+inspect $ hasNoTypeClassesExcept 'copyChunksSplitInterpose [''Unboxed]
204204inspect $ 'copyChunksSplitInterpose `hasNoType` ''Step
205205#endif
206206
benchmark/Streamly/Benchmark/Unicode/Stream.hs+2−2
@@ -35,7 +35,7 @@ import Streamly.Benchmark.Common
3535import Streamly.Benchmark.Common.Handle
3636
3737#ifdef INSPECTION
38−import Streamly.Internal.Data.Unboxed (Storable)
38+import Streamly.Internal.Data.Unboxed (Unboxed)
3939import Streamly.Internal.Data.Stream.StreamD.Type (Step(..))
4040import qualified Streamly.Internal.Data.Fold.Type as Fold
4141import qualified Streamly.Internal.Data.Tuple.Strict as Strict
@@ -105,7 +105,7 @@ linesUnlinesArrayCharCopy inh outh =
105105 $ Stream.unfold Handle.read inh
106106
107107#ifdef INSPECTION
108−inspect $ hasNoTypeClassesExcept 'linesUnlinesArrayCharCopy [''Storable]
108+inspect $ hasNoTypeClassesExcept 'linesUnlinesArrayCharCopy [''Unboxed]
109109-- inspect $ 'linesUnlinesArrayCharCopy `hasNoType` ''Step
110110#endif
111111
core/src/Streamly/Internal/Data/Array/Stream/Fold/Foreign.hs+5−5
@@ -60,7 +60,7 @@ import Control.Applicative (liftA2)
6060import Control.Exception (assert)
6161import Control.Monad.Catch (MonadThrow)
6262import Control.Monad.IO.Class (MonadIO(..))
63−import Streamly.Internal.Data.Unboxed (Storable, peekWith, sizeOf)
63+import Streamly.Internal.Data.Unboxed (peekWith, sizeOf, Unboxed)
6464import GHC.Types (SPEC(..))
6565import Streamly.Internal.Data.Array.Unboxed.Mut.Type (touch)
6666import Streamly.Internal.Data.Array.Unboxed.Type (Array(..))
@@ -97,7 +97,7 @@ newtype ArrayFold m a b = ArrayFold (ParserD.Parser m (Array a) b)
9797--
9898-- /Pre-release/
9999{-# INLINE fromFold #-}
100−fromFold :: forall m a b. (MonadIO m, Storable a) =>
100+fromFold :: forall m a b. (MonadIO m, Unboxed a) =>
101101 Fold.Fold m a b -> ArrayFold m a b
102102fromFold (Fold.Fold fstep finitial fextract) =
103103 ArrayFold (ParserD.Parser step initial fextract)
@@ -135,7 +135,7 @@ fromFold (Fold.Fold fstep finitial fextract) =
135135--
136136-- /Pre-release/
137137{-# INLINE fromParserD #-}
138−fromParserD :: forall m a b. (MonadIO m, Storable a) =>
138+fromParserD :: forall m a b. (MonadIO m, Unboxed a) =>
139139 ParserD.Parser m a b -> ArrayFold m a b
140140fromParserD (ParserD.Parser step1 initial1 extract1) =
141141 ArrayFold (ParserD.Parser step initial1 extract1)
@@ -177,7 +177,7 @@ fromParserD (ParserD.Parser step1 initial1 extract1) =
177177--
178178-- /Pre-release/
179179{-# INLINE fromParser #-}
180−fromParser :: forall m a b. (MonadThrow m, MonadIO m, Storable a) =>
180+fromParser :: forall m a b. (MonadThrow m, MonadIO m, Unboxed a) =>
181181 Parser.Parser m a b -> ArrayFold m a b
182182fromParser = fromParserD . ParserD.fromParserK
183183
@@ -301,7 +301,7 @@ instance MonadThrow m => Monad (ArrayFold m a) where
301301
302302-- | Take @n@ array elements (@a@) from a stream of arrays (@Array a@).
303303{-# INLINE take #-}
304−take :: forall m a b. (Monad m, Storable a) =>
304+take :: forall m a b. (Monad m, Unboxed a) =>
305305 Int -> ArrayFold m a b -> ArrayFold m a b
306306take n (ArrayFold (ParserD.Parser step1 initial1 extract1)) =
307307 ArrayFold $ ParserD.Parser step initial extract
core/src/Streamly/Internal/Data/Array/Stream/Mut/Foreign.hs+10−10
@@ -31,7 +31,7 @@ import Control.Monad.IO.Class (MonadIO(..))
3131import Control.Monad (when)
3232import Control.Monad.Catch (MonadThrow)
3333import Data.Bifunctor (first)
34−import Streamly.Internal.Data.Unboxed (Storable, sizeOf)
34+import Streamly.Internal.Data.Unboxed (Unboxed, sizeOf)
3535import Streamly.Internal.Data.Array.Unboxed.Mut.Type (Array(..))
3636import Streamly.Internal.Data.Fold.Type (Fold(..))
3737import Streamly.Internal.Data.Stream.Type (Stream)
@@ -52,7 +52,7 @@ import qualified Streamly.Internal.Data.Stream.Type as Stream
5252--
5353-- /Pre-release/
5454{-# INLINE arraysOf #-}
55−arraysOf :: (MonadIO m, Storable a)
55+arraysOf :: (MonadIO m, Unboxed a)
5656 => Int -> Stream m a -> Stream m (Array a)
5757arraysOf n = Stream.fromStreamD . MArray.arraysOf n . Stream.toStreamD
5858
@@ -81,7 +81,7 @@ data SpliceState s arr
8181--
8282-- @since 0.7.0
8383{-# INLINE_NORMAL packArraysChunksOf #-}
84−packArraysChunksOf :: (MonadIO m, Storable a)
84+packArraysChunksOf :: (MonadIO m, Unboxed a)
8585 => Int -> D.Stream m (Array a) -> D.Stream m (Array a)
8686packArraysChunksOf n (D.Stream step state) =
8787 D.Stream step' (SpliceInitial state)
@@ -129,7 +129,7 @@ packArraysChunksOf n (D.Stream step state) =
129129-- lpackArraysChunksOf = Fold.many compactLEFold
130130--
131131{-# INLINE_NORMAL lpackArraysChunksOf #-}
132−lpackArraysChunksOf :: (MonadIO m, Storable a)
132+lpackArraysChunksOf :: (MonadIO m, Unboxed a)
133133 => Int -> Fold m (Array a) () -> Fold m (Array a) ()
134134lpackArraysChunksOf n (Fold step1 initial1 extract1) =
135135 Fold step initial extract
@@ -191,7 +191,7 @@ lpackArraysChunksOf n (Fold step1 initial1 extract1) =
191191--
192192-- /Internal/
193193{-# INLINE compact #-}
194−compact :: (MonadIO m, Storable a)
194+compact :: (MonadIO m, Unboxed a)
195195 => Int -> Stream m (Array a) -> Stream m (Array a)
196196compact n = Stream.fromStreamD . packArraysChunksOf n . Stream.toStreamD
197197
@@ -204,7 +204,7 @@ compact n = Stream.fromStreamD . packArraysChunksOf n . Stream.toStreamD
204204-- /Internal/
205205{-# INLINE_NORMAL compactLEParserD #-}
206206compactLEParserD ::
207− forall m a. (MonadThrow m, MonadIO m, Storable a)
207+ forall m a. (MonadThrow m, MonadIO m, Unboxed a)
208208 => Int -> ParserD.Parser m (Array a) (Array a)
209209compactLEParserD n = ParserD.Parser step initial extract
210210
@@ -254,7 +254,7 @@ compactLEParserD n = ParserD.Parser step initial extract
254254-- /Internal/
255255{-# INLINE_NORMAL compactGEFold #-}
256256compactGEFold ::
257− forall m a. (MonadIO m, Storable a)
257+ forall m a. (MonadIO m, Unboxed a)
258258 => Int -> FL.Fold m (Array a) (Array a)
259259compactGEFold n = Fold step initial extract
260260
@@ -298,7 +298,7 @@ compactGEFold n = Fold step initial extract
298298-- maximum specified size in bytes.
299299--
300300-- /Internal/
301−compactLE :: (MonadThrow m, MonadIO m, Storable a) =>
301+compactLE :: (MonadThrow m, MonadIO m, Unboxed a) =>
302302 Int -> Stream m (Array a) -> Stream m (Array a)
303303compactLE n =
304304 Stream.fromStreamD . D.parseMany (compactLEParserD n) . Stream.toStreamD
@@ -308,7 +308,7 @@ compactLE n =
308308--
309309-- /Unimplemented/
310310{-# INLINE compactEQ #-}
311−compactEQ :: -- (MonadIO m, Storable a) =>
311+compactEQ :: -- (MonadIO m, Unboxed a) =>
312312 Int -> Stream m (Array a) -> Stream m (Array a)
313313compactEQ _n _xs = undefined
314314 -- IsStream.fromStreamD $ D.foldMany (compactEQFold n) (IsStream.toStreamD xs)
@@ -319,7 +319,7 @@ compactEQ _n _xs = undefined
319319-- /Internal/
320320{-# INLINE compactGE #-}
321321compactGE ::
322− (MonadIO m, Storable a)
322+ (MonadIO m, Unboxed a)
323323 => Int -> Stream m (Array a) -> Stream m (Array a)
324324compactGE n =
325325 Stream.fromStreamD . D.foldMany (compactGEFold n) . Stream.toStreamD
core/src/Streamly/Internal/Data/Array/Unboxed.hs+21−22
@@ -116,10 +116,8 @@ import Data.Functor.Identity (Identity)
116116import Data.Word (Word8)
117117import Foreign.C.String (CString)
118118import Foreign.Ptr (castPtr)
119−import qualified Foreign.Storable as Storable (Storable)
120119import Streamly.Internal.Data.Unboxed
121− ( Storable
122− , Unboxed
120+ ( Unboxed
123121 , castContents
124122 , peekWith
125123 , sizeOf
@@ -136,6 +134,7 @@ import Streamly.Internal.Data.Tuple.Strict (Tuple3Fused'(..))
136134import Streamly.Internal.Data.Unfold.Type (Unfold(..))
137135import Streamly.Internal.System.IO (unsafeInlineIO)
138136
137+import qualified Foreign.Storable as Storable
139138import qualified Streamly.Internal.Data.Array.Unboxed.Mut.Type as MA
140139import qualified Streamly.Internal.Data.Array.Unboxed.Mut as MA
141140import qualified Streamly.Internal.Data.Array.Unboxed.Type as A
@@ -158,7 +157,7 @@ import qualified Streamly.Internal.Data.Unfold as Unfold
158157--
159158-- /Pre-release/
160159{-# INLINE fromStreamN #-}
161−fromStreamN :: (MonadIO m, Storable a) => Int -> Stream m a -> m (Array a)
160+fromStreamN :: (MonadIO m, Unboxed a) => Int -> Stream m a -> m (Array a)
162161fromStreamN n m = do
163162 when (n < 0) $ error "writeN: negative write count specified"
164163 A.fromStreamDN n $ Stream.toStreamD m
@@ -173,7 +172,7 @@ fromStreamN n m = do
173172--
174173-- /Pre-release/
175174{-# INLINE fromStream #-}
176−fromStream :: (MonadIO m, Storable a) => Stream m a -> m (Array a)
175+fromStream :: (MonadIO m, Unboxed a) => Stream m a -> m (Array a)
177176fromStream m = P.fold A.write $ Stream.toStreamK m
178177-- write m = A.fromStreamD $ D.fromStreamK m
179178
@@ -182,7 +181,7 @@ fromStream m = P.fold A.write $ Stream.toStreamK m
182181-------------------------------------------------------------------------------
183182
184183{-# INLINE_NORMAL producer #-}
185−producer :: forall m a. (Monad m, Storable a) => Producer m (Array a) a
184+producer :: forall m a. (Monad m, Unboxed a) => Producer m (Array a) a
186185producer =
187186 Producer.translate A.unsafeThaw A.unsafeFreeze
188187 $ MA.producerWith (return . unsafeInlineIO)
@@ -193,7 +192,7 @@ producer =
193192--
194193-- @since 0.8.0
195194{-# INLINE_NORMAL read #-}
196−read :: forall m a. (Monad m, Storable a) => Unfold m (Array a) a
195+read :: forall m a. (Monad m, Unboxed a) => Unfold m (Array a) a
197196read = Producer.simplify producer
198197
199198-- | Unfold an array into a stream, does not check the end of the array, the
@@ -208,7 +207,7 @@ read = Producer.simplify producer
208207-- /Pre-release/
209208--
210209{-# INLINE_NORMAL unsafeRead #-}
211−unsafeRead :: forall m a. (Monad m, Storable a) => Unfold m (Array a) a
210+unsafeRead :: forall m a. (Monad m, Unboxed a) => Unfold m (Array a) a
212211unsafeRead = Unfold step inject
213212 where
214213
@@ -243,7 +242,7 @@ null arr = A.byteLength arr == 0
243242--
244243-- /Pre-release/
245244{-# INLINE getIndexRev #-}
246−getIndexRev :: forall a. Storable a => Int -> Array a -> Maybe a
245+getIndexRev :: forall a. Unboxed a => Int -> Array a -> Maybe a
247246getIndexRev i arr =
248247 unsafeInlineIO
249248 $ do
@@ -259,7 +258,7 @@ getIndexRev i arr =
259258--
260259-- /Pre-release/
261260{-# INLINE last #-}
262−last :: Storable a => Array a -> Maybe a
261+last :: Unboxed a => Array a -> Maybe a
263262last = getIndexRev 0
264263
265264-------------------------------------------------------------------------------
@@ -352,7 +351,7 @@ find = Unfold.fold Fold.null . Stream.unfold (findIndicesOf p)
352351-- /Pre-release/
353352{-# INLINE getSliceUnsafe #-}
354353getSliceUnsafe ::
355− forall a. Storable a
354+ forall a. Unboxed a
356355 => Int -- ^ starting index
357356 -> Int -- ^ length of the slice
358357 -> Array a
@@ -368,7 +367,7 @@ getSliceUnsafe index len (Array contents start e) =
368367--
369368-- /Pre-release/
370369{-# INLINE splitOn #-}
371−splitOn :: (Monad m, Storable a) =>
370+splitOn :: (Monad m, Unboxed a) =>
372371 (a -> Bool) -> Array a -> Stream m (Array a)
373372splitOn predicate arr =
374373 Stream.fromStreamD
@@ -376,7 +375,7 @@ splitOn predicate arr =
376375 $ D.sliceOnSuffix predicate (A.toStreamD arr)
377376
378377{-# INLINE genSlicesFromLen #-}
379−genSlicesFromLen :: forall m a. (Monad m, Storable a)
378+genSlicesFromLen :: forall m a. (Monad m, Unboxed a)
380379 => Int -- ^ from index
381380 -> Int -- ^ length of the slice
382381 -> Unfold m (Array a) (Int, Int)
@@ -389,7 +388,7 @@ genSlicesFromLen from len =
389388--
390389-- /Pre-release//
391390{-# INLINE getSlicesFromLen #-}
392−getSlicesFromLen :: forall m a. (Monad m, Storable a)
391+getSlicesFromLen :: forall m a. (Monad m, Unboxed a)
393392 => Int -- ^ from index
394393 -> Int -- ^ length of the slice
395394 -> Unfold m (Array a) (Array a)
@@ -408,7 +407,7 @@ getSlicesFromLen from len =
408407--
409408-- @since 0.8.0
410409{-# INLINE getIndex #-}
411−getIndex :: forall a. Storable a => Int -> Array a -> Maybe a
410+getIndex :: forall a. Unboxed a => Int -> Array a -> Maybe a
412411getIndex i arr =
413412 unsafeInlineIO
414413 $ do
@@ -435,7 +434,7 @@ getIndex i arr =
435434--
436435-- /Pre-release/
437436{-# INLINE getIndices #-}
438−getIndices :: (Monad m, Storable a) => Stream m Int -> Unfold m (Array a) a
437+getIndices :: (Monad m, Unboxed a) => Stream m Int -> Unfold m (Array a) a
439438getIndices m =
440439 let unf = MA.getIndicesD (return . unsafeInlineIO) $ D.fromStreamK $ Stream.toStreamK m
441440 in Unfold.lmap A.unsafeThaw unf
@@ -472,7 +471,7 @@ getIndicesFromThenTo = undefined
472471--
473472-- @since 0.7.0
474473{-# INLINE runPipe #-}
475−runPipe :: (MonadIO m, Storable a, Storable b)
474+runPipe :: (MonadIO m, Unboxed a, Unboxed b)
476475 => Pipe m a b -> Array a -> m (Array b)
477476runPipe f arr = P.runPipe (toArrayMinChunk (length arr)) $ f (A.read arr)
478477-}
@@ -485,7 +484,7 @@ runPipe f arr = P.runPipe (toArrayMinChunk (length arr)) $ f (A.read arr)
485484--
486485-- /Pre-release/
487486{-# INLINE streamTransform #-}
488−streamTransform :: forall m a b. (MonadIO m, Storable a, Storable b)
487+streamTransform :: forall m a b. (MonadIO m, Unboxed a, Unboxed b)
489488 => (Stream m a -> Stream m b) -> Array a -> m (Array b)
490489streamTransform f arr =
491490 P.fold (A.writeWith (length arr)) $ Stream.toStreamK $ f (A.toStream arr)
@@ -503,7 +502,7 @@ streamTransform f arr =
503502--
504503castUnsafe ::
505504#ifdef DEVBUILD
506− Storable b =>
505+ Unboxed b =>
507506#endif
508507 Array a -> Array b
509508castUnsafe (Array contents start end) =
@@ -522,7 +521,7 @@ asBytes = castUnsafe
522521--
523522-- @since 0.8.0
524523--
525−cast :: forall a b. (Storable b) => Array a -> Maybe (Array b)
524+cast :: forall a b. (Unboxed b) => Array a -> Maybe (Array b)
526525cast arr =
527526 let len = A.byteLength arr
528527 r = len `mod` SIZE_OF(b)
@@ -552,12 +551,12 @@ asCStringUnsafe arr act = do
552551--
553552-- /Pre-release/
554553{-# INLINE fold #-}
555−fold :: forall m a b. (Monad m, Storable a) => Fold m a b -> Array a -> m b
554+fold :: forall m a b. (Monad m, Unboxed a) => Fold m a b -> Array a -> m b
556555fold f arr = P.fold f (Stream.toStreamK (A.toStream arr))
557556
558557-- | Fold an array using a stream fold operation.
559558--
560559-- /Pre-release/
561560{-# INLINE streamFold #-}
562−streamFold :: (Monad m, Storable a) => (Stream m a -> m b) -> Array a -> m b
561+streamFold :: (Monad m, Unboxed a) => (Stream m a -> m b) -> Array a -> m b
563562streamFold f arr = f (A.toStream arr)
core/src/Streamly/Internal/Data/Array/Unboxed/Mut.hs+6−6
@@ -8,7 +8,7 @@
88-- Stability : experimental
99-- Portability : GHC
1010--
11−-- Unboxed pinned mutable array type for 'Storable' types with an option to use
11+-- Unboxed pinned mutable array type for 'Unboxed' types with an option to use
1212-- foreign (non-GHC) memory allocators. Fulfils the following goals:
1313--
1414-- * Random access (array)
@@ -33,7 +33,7 @@ module Streamly.Internal.Data.Array.Unboxed.Mut
3333where
3434
3535import Control.Monad.IO.Class (MonadIO(..))
36−import Streamly.Internal.Data.Unboxed (Storable)
36+import Streamly.Internal.Data.Unboxed (Unboxed)
3737import Streamly.Internal.Data.Stream (Stream)
3838import Streamly.Internal.Data.Unfold.Type (Unfold(..))
3939
@@ -50,7 +50,7 @@ import Streamly.Internal.Data.Array.Unboxed.Mut.Type
5050--
5151-- /Pre-release/
5252{-# INLINE splitOn #-}
53−splitOn :: (MonadIO m, Storable a) =>
53+splitOn :: (MonadIO m, Unboxed a) =>
5454 (a -> Bool) -> Array a -> Stream m (Array a)
5555splitOn predicate arr =
5656 Stream.fromStreamD
@@ -63,7 +63,7 @@ splitOn predicate arr =
6363--
6464-- /Pre-release/
6565{-# INLINE genSlicesFromLen #-}
66−genSlicesFromLen :: forall m a. (Monad m, Storable a)
66+genSlicesFromLen :: forall m a. (Monad m, Unboxed a)
6767 => Int -- ^ from index
6868 -> Int -- ^ length of the slice
6969 -> Unfold m (Array a) (Int, Int)
@@ -80,7 +80,7 @@ genSlicesFromLen from len =
8080--
8181-- /Pre-release/
8282{-# INLINE getSlicesFromLen #-}
83−getSlicesFromLen :: forall m a. (Monad m, Storable a)
83+getSlicesFromLen :: forall m a. (Monad m, Unboxed a)
8484 => Int -- ^ from index
8585 -> Int -- ^ length of the slice
8686 -> Unfold m (Array a) (Array a)
@@ -98,6 +98,6 @@ getSlicesFromLen from len =
9898--
9999-- /Pre-release/
100100{-# INLINE fromStream #-}
101−fromStream :: (MonadIO m, Storable a) => Stream m a -> m (Array a)
101+fromStream :: (MonadIO m, Unboxed a) => Stream m a -> m (Array a)
102102fromStream = fromStreamD . Stream.toStreamD
103103-- fromStream (Stream m) = P.fold write m
core/src/Streamly/Internal/Data/Array/Unboxed/Mut/Type.hs+106−106
@@ -228,7 +228,7 @@ import Foreign.Ptr (plusPtr, minusPtr, nullPtr)
228228import Streamly.Internal.Control.Exception (assertM)
229229import Streamly.Internal.Data.Unboxed
230230 ( ArrayContents(..)
231− , Storable
231+ , Unboxed
232232 , alignment
233233 , castContents
234234 , getMutableByteArray#
@@ -289,11 +289,11 @@ foreign import ccall unsafe "string.h memchr" c_memchr
289289foreign import ccall unsafe "string.h memcmp" c_memcmp
290290 :: Ptr Word8 -> Ptr Word8 -> CSize -> IO CInt
291291
292−-- | Given a 'Storable' type (unused first arg) and a number of bytes, return
292+-- | Given an 'Unboxed' type (unused first arg) and a number of bytes, return
293293-- how many elements of that type will completely fit in those bytes.
294294--
295295{-# INLINE bytesToElemCount #-}
296−bytesToElemCount :: forall a. Storable a => a -> Int -> Int
296+bytesToElemCount :: forall a. Unboxed a => a -> Int -> Int
297297bytesToElemCount _ n = n `div` SIZE_OF(a)
298298
299299-- XXX we are converting Int to CSize
@@ -314,7 +314,7 @@ memcmp p1 p2 len = do
314314
315315-- $arrayNotes
316316--
317−-- We can use a 'Storable' constraint in the Array type and the constraint can
317+-- We can use an 'Unboxed' constraint in the Array type and the constraint can
318318-- be automatically provided to a function that pattern matches on the Array
319319-- type. However, it has huge performance cost, so we do not use it.
320320-- Investigate a GHC improvement possiblity.
@@ -340,7 +340,7 @@ memcmp p1 p2 len = do
340340--
341341data Array a =
342342#ifdef DEVBUILD
343− Storable a =>
343+ Unboxed a =>
344344#endif
345345 -- The array is a range into arrContents. arrContents may be a superset of
346346 -- the slice represented by the array. All offsets are in bytes.
@@ -394,7 +394,7 @@ unpin arr@(Array{..}) = do
394394--
395395-- /Pre-release/
396396{-# INLINE newArrayWith #-}
397−newArrayWith :: forall m a. (MonadIO m, Storable a)
397+newArrayWith :: forall m a. (MonadIO m, Unboxed a)
398398 => (Int -> Int -> m (ArrayContents a)) -> Int -> Int -> m (Array a)
399399newArrayWith alloc alignSize count = do
400400 let size = max (count * SIZE_OF(a)) 0
@@ -425,17 +425,17 @@ nilArrayContents =
425425
426426nil ::
427427#ifdef DEVBUILD
428− Storable a =>
428+ Unboxed a =>
429429#endif
430430 Array a
431431nil = Array nilArrayContents 0 0 0
432432
433433-- | Like 'newArrayWith' but using an allocator that aligns the memory to the
434−-- alignment dictated by the 'Storable' instance of the type.
434+-- alignment dictated by the 'Unboxed' instance of the type.
435435--
436436-- /Internal/
437437{-# INLINE newArrayAligned #-}
438−newArrayAligned :: (MonadIO m, Storable a) => Int -> Int -> m (Array a)
438+newArrayAligned :: (MonadIO m, Unboxed a) => Int -> Int -> m (Array a)
439439newArrayAligned = newArrayWith (\s a -> liftIO $ newAlignedArrayContents s a)
440440
441441-- XXX Intead of newArray, make newPinnedArray and newUnpinnedArray. Make it
@@ -443,21 +443,21 @@ newArrayAligned = newArrayWith (\s a -> liftIO $ newAlignedArrayContents s a)
443443-- XXX can unaligned allocation be more efficient when alignment is not needed?
444444--
445445-- | Allocates an empty array that can hold 'count' items. The memory of the
446−-- array is uninitialized and the allocation is aligned as per the 'Storable'
446+-- array is uninitialized and the allocation is aligned as per the 'Unboxed'
447447-- instance of the type.
448448--
449449-- /Pre-release/
450450{-# INLINE newArray #-}
451−newArray :: forall m a. (MonadIO m, Storable a) => Int -> m (Array a)
451+newArray :: forall m a. (MonadIO m, Unboxed a) => Int -> m (Array a)
452452newArray = newArrayAligned (alignment (undefined :: a))
453453
454454-- | Allocates a pinned empty array that can hold 'count' items. The memory of
455455-- the array is uninitialized and the allocation is aligned as per the
456−-- 'Storable' instance of the type.
456+-- 'Unboxed' instance of the type.
457457--
458458-- /Pre-release/
459459{-# INLINE newPinnedArrayBytes #-}
460−newPinnedArrayBytes :: forall m a. (MonadIO m, Storable a) => Int -> m (Array a)
460+newPinnedArrayBytes :: forall m a. (MonadIO m, Unboxed a) => Int -> m (Array a)
461461newPinnedArrayBytes bytes = do
462462 contents <-
463463 liftIO $ newAlignedArrayContents bytes (alignment (undefined :: a))
@@ -474,7 +474,7 @@ newPinnedArrayBytes bytes = do
474474-- /Internal/
475475{-# INLINE withNewArrayUnsafe #-}
476476withNewArrayUnsafe ::
477− (MonadIO m, Storable a) => Int -> (Ptr a -> m ()) -> m (Array a)
477+ (MonadIO m, Unboxed a) => Int -> (Ptr a -> m ()) -> m (Array a)
478478withNewArrayUnsafe count f = do
479479 arr <- newArray count
480480 asPtrUnsafe arr
@@ -489,7 +489,7 @@ withNewArrayUnsafe count f = do
489489--
490490-- /Pre-release/
491491{-# INLINE putIndexUnsafe #-}
492−putIndexUnsafe :: forall m a. (MonadIO m, Storable a)
492+putIndexUnsafe :: forall m a. (MonadIO m, Unboxed a)
493493 => Int -> a -> Array a -> m ()
494494putIndexUnsafe i x (Array {..}) = do
495495 let index = INDEX_OF(arrStart, i, a)
@@ -509,7 +509,7 @@ invalidIndex label i =
509509--
510510-- /Pre-release/
511511{-# INLINE putIndex #-}
512−putIndex :: forall m a. (MonadIO m, Storable a) => Int -> a -> Array a -> m ()
512+putIndex :: forall m a. (MonadIO m, Unboxed a) => Int -> a -> Array a -> m ()
513513putIndex i x Array{..} = do
514514 let index = INDEX_OF(arrStart,i,a)
515515 if i >= 0 && INDEX_VALID(index,aEnd,a)
@@ -521,7 +521,7 @@ putIndex i x Array{..} = do
521521--
522522-- /Pre-release/
523523{-# INLINE putIndices #-}
524−putIndices :: forall m a. (MonadIO m, Storable a)
524+putIndices :: forall m a. (MonadIO m, Unboxed a)
525525 => Array a -> Fold m (Int, a) ()
526526putIndices arr = FL.foldlM' step (return ())
527527
@@ -532,7 +532,7 @@ putIndices arr = FL.foldlM' step (return ())
532532-- | Modify a given index of an array using a modifier function.
533533--
534534-- /Pre-release/
535−modifyIndexUnsafe :: forall m a b. (MonadIO m, Storable a) =>
535+modifyIndexUnsafe :: forall m a b. (MonadIO m, Unboxed a) =>
536536 Int -> (a -> (a, b)) -> Array a -> m b
537537modifyIndexUnsafe i f (Array{..}) = liftIO $ do
538538 let index = INDEX_OF(arrStart,i,a)
@@ -545,7 +545,7 @@ modifyIndexUnsafe i f (Array{..}) = liftIO $ do
545545-- | Modify a given index of an array using a modifier function.
546546--
547547-- /Pre-release/
548−modifyIndex :: forall m a b. (MonadIO m, Storable a) =>
548+modifyIndex :: forall m a b. (MonadIO m, Unboxed a) =>
549549 Int -> (a -> (a, b)) -> Array a -> m b
550550modifyIndex i f Array{..} = do
551551 let index = INDEX_OF(arrStart,i,a)
@@ -562,7 +562,7 @@ modifyIndex i f Array{..} = do
562562--
563563-- /Pre-release/
564564{-# INLINE modifyIndices #-}
565−modifyIndices :: forall m a . (MonadIO m, Storable a)
565+modifyIndices :: forall m a . (MonadIO m, Unboxed a)
566566 => (Int -> a -> a) -> Array a -> Fold m Int ()
567567modifyIndices f arr = FL.foldlM' step initial
568568
@@ -577,7 +577,7 @@ modifyIndices f arr = FL.foldlM' step initial
577577-- | Modify each element of an array using the supplied modifier function.
578578--
579579-- /Pre-release/
580−modify :: forall m a. (MonadIO m, Storable a)
580+modify :: forall m a. (MonadIO m, Unboxed a)
581581 => (a -> a) -> Array a -> m ()
582582modify f Array{..} = liftIO $
583583 go arrStart
@@ -591,7 +591,7 @@ modify f Array{..} = liftIO $
591591 go (INDEX_NEXT(i,a))
592592
593593{-# INLINE swapArrayByteIndices #-}
594−swapArrayByteIndices :: Storable a => ArrayContents a -> Int -> Int -> IO ()
594+swapArrayByteIndices :: Unboxed a => ArrayContents a -> Int -> Int -> IO ()
595595swapArrayByteIndices arrContents i1 i2 = do
596596 r1 <- peekWith arrContents i1
597597 r2 <- peekWith arrContents i2
@@ -604,7 +604,7 @@ swapArrayByteIndices arrContents i1 i2 = do
604604--
605605-- /Pre-release/
606606{-# INLINE unsafeSwapIndices #-}
607−unsafeSwapIndices :: forall m a. (MonadIO m, Storable a)
607+unsafeSwapIndices :: forall m a. (MonadIO m, Unboxed a)
608608 => Int -> Int -> Array a -> m ()
609609unsafeSwapIndices i1 i2 Array{..} = liftIO $ do
610610 let t1 = INDEX_OF(arrStart,i1,a)
@@ -614,7 +614,7 @@ unsafeSwapIndices i1 i2 Array{..} = liftIO $ do
614614-- | Swap the elements at two indices.
615615--
616616-- /Pre-release/
617−swapIndices :: forall m a. (MonadIO m, Storable a)
617+swapIndices :: forall m a. (MonadIO m, Unboxed a)
618618 => Int -> Int -> Array a -> m ()
619619swapIndices i1 i2 Array{..} = liftIO $ do
620620 let t1 = INDEX_OF(arrStart,i1,a)
@@ -685,15 +685,15 @@ roundUpToPower2 n =
685685-- case it returns one element's size.
686686--
687687{-# INLINE allocBytesToBytes #-}
688−allocBytesToBytes :: forall a. Storable a => a -> Int -> Int
688+allocBytesToBytes :: forall a. Unboxed a => a -> Int -> Int
689689allocBytesToBytes _ n = max (arrayPayloadSize n) (SIZE_OF(a))
690690
691−-- | Given a 'Storable' type (unused first arg) and real allocation size
691+-- | Given an 'Unboxed' type (unused first arg) and real allocation size
692692-- (including overhead), return how many elements of that type will completely
693693-- fit in it, returns at least 1.
694694--
695695{-# INLINE allocBytesToElemCount #-}
696−allocBytesToElemCount :: Storable a => a -> Int -> Int
696+allocBytesToElemCount :: Unboxed a => a -> Int -> Int
697697allocBytesToElemCount x bytes =
698698 let n = bytesToElemCount x (allocBytesToBytes x bytes)
699699 in assert (n >= 1) n
@@ -715,8 +715,8 @@ roundDownTo elemSize size = size - (size `mod` elemSize)
715715-- XXX See if resizing can be implemented by reading the old array as a stream
716716-- and then using writeN to the new array.
717717--
718−-- NOTE: we are passing elemSize explicitly to avoid a Storable constraint.
719−-- Since this is not inlined Storable consrraint leads to dictionary passing
718+-- NOTE: we are passing elemSize explicitly to avoid an Unboxed constraint.
719+-- Since this is not inlined Unboxed consrraint leads to dictionary passing
720720-- which complicates some inspection tests.
721721--
722722{-# NOINLINE reallocAligned #-}
@@ -758,14 +758,14 @@ reallocAligned elemSize alignSize newCapacityInBytes Array{..} = do
758758-- 'largeObjectThreshold' then it is rounded up to the block size (4K).
759759--
760760{-# INLINABLE realloc #-}
761−realloc :: forall m a. (MonadIO m, Storable a) => Int -> Array a -> m (Array a)
761+realloc :: forall m a. (MonadIO m, Unboxed a) => Int -> Array a -> m (Array a)
762762realloc bytes arr =
763763 liftIO $ reallocAligned (SIZE_OF(a)) (alignment (undefined :: a)) bytes arr
764764
765765-- | @reallocWith label capSizer minIncrBytes array@. The label is used
766766-- in error messages and the capSizer is used to determine the capacity of the
767767-- new array in bytes given the current byte length of the array.
768−reallocWith :: forall m a. (MonadIO m , Storable a) =>
768+reallocWith :: forall m a. (MonadIO m , Unboxed a) =>
769769 String
770770 -> (Int -> Int)
771771 -> Int
@@ -799,7 +799,7 @@ reallocWith label capSizer minIncrBytes arr = do
799799--
800800-- /Pre-release/
801801{-# INLINE resize #-}
802−resize :: forall m a. (MonadIO m, Storable a) =>
802+resize :: forall m a. (MonadIO m, Unboxed a) =>
803803 Int -> Array a -> m (Array a)
804804resize nElems arr@Array{..} = do
805805 let req = SIZE_OF(a) * nElems
@@ -813,7 +813,7 @@ resize nElems arr@Array{..} = do
813813--
814814-- /Pre-release/
815815{-# INLINE resizeExp #-}
816−resizeExp :: forall m a. (MonadIO m, Storable a) =>
816+resizeExp :: forall m a. (MonadIO m, Unboxed a) =>
817817 Int -> Array a -> m (Array a)
818818resizeExp nElems arr@Array{..} = do
819819 let req = roundUpLargeArray (SIZE_OF(a) * nElems)
@@ -835,7 +835,7 @@ resizeExp nElems arr@Array{..} = do
835835--
836836-- /Pre-release/
837837{-# INLINE rightSize #-}
838−rightSize :: forall m a. (MonadIO m, Storable a) => Array a -> m (Array a)
838+rightSize :: forall m a. (MonadIO m, Unboxed a) => Array a -> m (Array a)
839839rightSize arr@Array{..} = do
840840 assert (aEnd <= aBound) (return ())
841841 let start = arrStart
@@ -867,7 +867,7 @@ rightSize arr@Array{..} = do
867867--
868868-- /Internal/
869869{-# INLINE snocNewEnd #-}
870−snocNewEnd :: (MonadIO m, Storable a) => Int -> Array a -> a -> m (Array a)
870+snocNewEnd :: (MonadIO m, Unboxed a) => Int -> Array a -> a -> m (Array a)
871871snocNewEnd newEnd arr@Array{..} x = liftIO $ do
872872 assert (newEnd <= aBound) (return ())
873873 pokeWith arrContents aEnd x
@@ -879,7 +879,7 @@ snocNewEnd newEnd arr@Array{..} x = liftIO $ do
879879--
880880-- /Internal/
881881{-# INLINE snocUnsafe #-}
882−snocUnsafe :: forall m a. (MonadIO m, Storable a) =>
882+snocUnsafe :: forall m a. (MonadIO m, Unboxed a) =>
883883 Array a -> a -> m (Array a)
884884snocUnsafe arr@Array{..} = snocNewEnd (INDEX_NEXT(aEnd,a)) arr
885885
@@ -888,7 +888,7 @@ snocUnsafe arr@Array{..} = snocNewEnd (INDEX_NEXT(aEnd,a)) arr
888888--
889889-- /Internal/
890890{-# INLINE snocMay #-}
891−snocMay :: forall m a. (MonadIO m, Storable a) =>
891+snocMay :: forall m a. (MonadIO m, Unboxed a) =>
892892 Array a -> a -> m (Maybe (Array a))
893893snocMay arr@Array{..} x = liftIO $ do
894894 let newEnd = INDEX_NEXT(aEnd,a)
@@ -898,7 +898,7 @@ snocMay arr@Array{..} x = liftIO $ do
898898
899899-- NOINLINE to move it out of the way and not pollute the instruction cache.
900900{-# NOINLINE snocWithRealloc #-}
901−snocWithRealloc :: forall m a. (MonadIO m, Storable a) =>
901+snocWithRealloc :: forall m a. (MonadIO m, Unboxed a) =>
902902 (Int -> Int)
903903 -> Array a
904904 -> a
@@ -921,7 +921,7 @@ snocWithRealloc sizer arr x = do
921921--
922922-- /Pre-release/
923923{-# INLINE snocWith #-}
924−snocWith :: forall m a. (MonadIO m, Storable a) =>
924+snocWith :: forall m a. (MonadIO m, Unboxed a) =>
925925 (Int -> Int)
926926 -> Array a
927927 -> a
@@ -943,7 +943,7 @@ snocWith allocSize arr x = liftIO $ do
943943--
944944-- /Pre-release/
945945{-# INLINE snocLinear #-}
946−snocLinear :: forall m a. (MonadIO m, Storable a) => Array a -> a -> m (Array a)
946+snocLinear :: forall m a. (MonadIO m, Unboxed a) => Array a -> a -> m (Array a)
947947snocLinear = snocWith (+ allocBytesToBytes (undefined :: a) arrayChunkBytes)
948948
949949-- | The array is mutated to append an additional element to it. If there is no
@@ -961,7 +961,7 @@ snocLinear = snocWith (+ allocBytesToBytes (undefined :: a) arrayChunkBytes)
961961--
962962-- /Pre-release/
963963{-# INLINE snoc #-}
964−snoc :: forall m a. (MonadIO m, Storable a) => Array a -> a -> m (Array a)
964+snoc :: forall m a. (MonadIO m, Unboxed a) => Array a -> a -> m (Array a)
965965snoc = snocWith f
966966
967967 where
@@ -981,7 +981,7 @@ snoc = snocWith f
981981--
982982-- Unsafe because it does not check the bounds of the array.
983983{-# INLINE_NORMAL getIndexUnsafe #-}
984−getIndexUnsafe :: forall m a. (MonadIO m, Storable a) => Int -> Array a -> m a
984+getIndexUnsafe :: forall m a. (MonadIO m, Unboxed a) => Int -> Array a -> m a
985985getIndexUnsafe i (Array {..}) = do
986986 let index = INDEX_OF(arrStart,i,a)
987987 assert (i >= 0 && INDEX_VALID(index,aEnd,a)) (return ())
@@ -990,7 +990,7 @@ getIndexUnsafe i (Array {..}) = do
990990-- | /O(1)/ Lookup the element at the given index. Index starts from 0.
991991--
992992{-# INLINE getIndex #-}
993−getIndex :: forall m a. (MonadIO m, Storable a) => Int -> Array a -> m a
993+getIndex :: forall m a. (MonadIO m, Unboxed a) => Int -> Array a -> m a
994994getIndex i Array{..} = do
995995 let index = INDEX_OF(arrStart,i,a)
996996 if i >= 0 && INDEX_VALID(index,aEnd,a)
@@ -1003,7 +1003,7 @@ getIndex i Array{..} = do
10031003-- Slightly faster than computing the forward index and using getIndex.
10041004--
10051005{-# INLINE getIndexRev #-}
1006−getIndexRev :: forall m a. (MonadIO m, Storable a) => Int -> Array a -> m a
1006+getIndexRev :: forall m a. (MonadIO m, Unboxed a) => Int -> Array a -> m a
10071007getIndexRev i Array{..} = do
10081008 let index = RINDEX_OF(aEnd,i,a)
10091009 if i >= 0 && index >= arrStart
@@ -1019,7 +1019,7 @@ data GetIndicesState contents start end st =
10191019--
10201020-- /Pre-release/
10211021{-# INLINE getIndicesD #-}
1022−getIndicesD :: (Monad m, Storable a) =>
1022+getIndicesD :: (Monad m, Unboxed a) =>
10231023 (forall b. IO b -> m b) -> D.Stream m Int -> Unfold m (Array a) a
10241024getIndicesD liftio (D.Stream stepi sti) = Unfold step inject
10251025
@@ -1039,7 +1039,7 @@ getIndicesD liftio (D.Stream stepi sti) = Unfold step inject
10391039 D.Stop -> return D.Stop
10401040
10411041{-# INLINE getIndices #-}
1042−getIndices :: (MonadIO m, Storable a) => Stream m Int -> Unfold m (Array a) a
1042+getIndices :: (MonadIO m, Unboxed a) => Stream m Int -> Unfold m (Array a) a
10431043getIndices = getIndicesD liftIO . Stream.toStreamD
10441044
10451045-------------------------------------------------------------------------------
@@ -1056,7 +1056,7 @@ getIndices = getIndicesD liftIO . Stream.toStreamD
10561056--
10571057-- /Pre-release/
10581058{-# INLINE getSliceUnsafe #-}
1059−getSliceUnsafe :: forall a. Storable a
1059+getSliceUnsafe :: forall a. Unboxed a
10601060 => Int -- ^ from index
10611061 -> Int -- ^ length of the slice
10621062 -> Array a
@@ -1075,7 +1075,7 @@ getSliceUnsafe index len (Array contents start e _) =
10751075--
10761076-- /Pre-release/
10771077{-# INLINE getSlice #-}
1078−getSlice :: forall a. Storable a =>
1078+getSlice :: forall a. Unboxed a =>
10791079 Int -- ^ from index
10801080 -> Int -- ^ length of the slice
10811081 -> Array a
@@ -1104,7 +1104,7 @@ getSlice index len (Array contents start e _) =
11041104--
11051105-- /Pre-release/
11061106{-# INLINE reverse #-}
1107−reverse :: forall m a. (MonadIO m, Storable a) => Array a -> m ()
1107+reverse :: forall m a. (MonadIO m, Unboxed a) => Array a -> m ()
11081108reverse Array{..} = liftIO $ do
11091109 let l = arrStart
11101110 h = INDEX_PREV(aEnd,a)
@@ -1131,7 +1131,7 @@ permute = undefined
11311131--
11321132-- /Pre-release/
11331133{-# INLINE partitionBy #-}
1134−partitionBy :: forall m a. (MonadIO m, Storable a)
1134+partitionBy :: forall m a. (MonadIO m, Unboxed a)
11351135 => (a -> Bool) -> Array a -> m (Array a, Array a)
11361136partitionBy f arr@Array{..} = liftIO $ do
11371137 if arrStart >= aEnd
@@ -1255,7 +1255,7 @@ byteLength Array{..} =
12551255--
12561256-- @since 0.7.0
12571257{-# INLINE length #-}
1258−length :: forall a. Storable a => Array a -> Int
1258+length :: forall a. Unboxed a => Array a -> Int
12591259length arr =
12601260 let elemSize = SIZE_OF(a)
12611261 blen = byteLength arr
@@ -1299,7 +1299,7 @@ data GroupState s contents start end bound
12991299--
13001300-- /Pre-release/
13011301{-# INLINE_NORMAL arraysOf #-}
1302−arraysOf :: forall m a. (MonadIO m, Storable a)
1302+arraysOf :: forall m a. (MonadIO m, Unboxed a)
13031303 => Int -> D.Stream m a -> D.Stream m (Array a)
13041304-- XXX the idiomatic implementation leads to large regression in the D.reverse'
13051305-- benchmark. It seems it has difficulty producing optimized code when
@@ -1346,7 +1346,7 @@ arraysOf n (D.Stream step state) =
13461346-- XXX buffer to a list instead?
13471347-- | Buffer the stream into arrays in memory.
13481348{-# INLINE arrayStreamKFromStreamD #-}
1349−arrayStreamKFromStreamD :: forall m a. (MonadIO m, Storable a) =>
1349+arrayStreamKFromStreamD :: forall m a. (MonadIO m, Unboxed a) =>
13501350 D.Stream m a -> m (K.Stream m (Array a))
13511351arrayStreamKFromStreamD =
13521352 let n = allocBytesToElemCount (undefined :: a) defaultChunkSize
@@ -1367,7 +1367,7 @@ data FlattenState s contents a =
13671367-- We can try this if there are any fusion issues in the unfold.
13681368--
13691369{-# INLINE_NORMAL flattenArrays #-}
1370−flattenArrays :: forall m a. (MonadIO m, Storable a)
1370+flattenArrays :: forall m a. (MonadIO m, Unboxed a)
13711371 => D.Stream m (Array a) -> D.Stream m a
13721372flattenArrays (D.Stream step state) = D.Stream step' (OuterLoop state)
13731373
@@ -1396,7 +1396,7 @@ flattenArrays (D.Stream step state) = D.Stream step' (OuterLoop state)
13961396-- We can try this if there are any fusion issues in the unfold.
13971397--
13981398{-# INLINE_NORMAL flattenArraysRev #-}
1399−flattenArraysRev :: forall m a. (MonadIO m, Storable a)
1399+flattenArraysRev :: forall m a. (MonadIO m, Unboxed a)
14001400 => D.Stream m (Array a) -> D.Stream m a
14011401flattenArraysRev (D.Stream step state) = D.Stream step' (OuterLoop state)
14021402
@@ -1436,7 +1436,7 @@ toArrayUnsafe (Array contents start end _) = ArrayUnsafe contents start end
14361436
14371437fromArrayUnsafe ::
14381438#ifdef DEVBUILD
1439− Storable a =>
1439+ Unboxed a =>
14401440#endif
14411441 ArrayUnsafe a -> Array a
14421442fromArrayUnsafe (ArrayUnsafe contents start end) =
@@ -1444,7 +1444,7 @@ fromArrayUnsafe (ArrayUnsafe contents start end) =
14441444
14451445{-# INLINE_NORMAL producerWith #-}
14461446producerWith ::
1447− forall m a. (Monad m, Storable a)
1447+ forall m a. (Monad m, Unboxed a)
14481448 => (forall b. IO b -> m b) -> Producer m (Array a) a
14491449producerWith liftio = Producer step (return . toArrayUnsafe) extract
14501450 where
@@ -1465,19 +1465,19 @@ producerWith liftio = Producer step (return . toArrayUnsafe) extract
14651465-- | Resumable unfold of an array.
14661466--
14671467{-# INLINE_NORMAL producer #-}
1468−producer :: forall m a. (MonadIO m, Storable a) => Producer m (Array a) a
1468+producer :: forall m a. (MonadIO m, Unboxed a) => Producer m (Array a) a
14691469producer = producerWith liftIO
14701470
14711471-- | Unfold an array into a stream.
14721472--
14731473-- @since 0.7.0
14741474{-# INLINE_NORMAL read #-}
1475−read :: forall m a. (MonadIO m, Storable a) => Unfold m (Array a) a
1475+read :: forall m a. (MonadIO m, Unboxed a) => Unfold m (Array a) a
14761476read = Producer.simplify producer
14771477
14781478{-# INLINE_NORMAL readRevWith #-}
14791479readRevWith ::
1480− forall m a. (Monad m, Storable a)
1480+ forall m a. (Monad m, Unboxed a)
14811481 => (forall b. IO b -> m b) -> Unfold m (Array a) a
14821482readRevWith liftio = Unfold step inject
14831483 where
@@ -1496,7 +1496,7 @@ readRevWith liftio = Unfold step inject
14961496--
14971497-- /Pre-release/
14981498{-# INLINE_NORMAL readRev #-}
1499−readRev :: forall m a. (MonadIO m, Storable a) => Unfold m (Array a) a
1499+readRev :: forall m a. (MonadIO m, Unboxed a) => Unfold m (Array a) a
15001500readRev = readRevWith liftIO
15011501
15021502-------------------------------------------------------------------------------
@@ -1507,7 +1507,7 @@ readRev = readRevWith liftIO
15071507-- Use foldr/build fusion to fuse with list consumers
15081508-- This can be useful when using the IsList instance
15091509{-# INLINE_LATE toListFB #-}
1510−toListFB :: forall a b. Storable a => (a -> b -> b) -> b -> Array a -> b
1510+toListFB :: forall a b. Unboxed a => (a -> b -> b) -> b -> Array a -> b
15111511toListFB c n Array{..} = go arrStart
15121512 where
15131513
@@ -1532,7 +1532,7 @@ toListFB c n Array{..} = go arrStart
15321532--
15331533-- @since 0.7.0
15341534{-# INLINE toList #-}
1535−toList :: forall m a. (MonadIO m, Storable a) => Array a -> m [a]
1535+toList :: forall m a. (MonadIO m, Unboxed a) => Array a -> m [a]
15361536toList Array{..} = liftIO $ go arrStart
15371537 where
15381538
@@ -1543,7 +1543,7 @@ toList Array{..} = liftIO $ go arrStart
15431543
15441544{-# INLINE_NORMAL toStreamDWith #-}
15451545toStreamDWith ::
1546− forall m a. (Monad m, Storable a)
1546+ forall m a. (Monad m, Unboxed a)
15471547 => (forall b. IO b -> m b) -> Array a -> D.Stream m a
15481548toStreamDWith liftio Array{..} = D.Stream step arrStart
15491549
@@ -1561,12 +1561,12 @@ toStreamDWith liftio Array{..} = D.Stream step arrStart
15611561--
15621562-- We can try this if the unfold has any performance issues.
15631563{-# INLINE_NORMAL toStreamD #-}
1564−toStreamD :: forall m a. (MonadIO m, Storable a) => Array a -> D.Stream m a
1564+toStreamD :: forall m a. (MonadIO m, Unboxed a) => Array a -> D.Stream m a
15651565toStreamD = toStreamDWith liftIO
15661566
15671567{-# INLINE toStreamKWith #-}
15681568toStreamKWith ::
1569− forall m a. (Monad m, Storable a)
1569+ forall m a. (Monad m, Unboxed a)
15701570 => (forall b. IO b -> m b) -> Array a -> K.Stream m a
15711571toStreamKWith liftio Array{..} = go arrStart
15721572
@@ -1580,12 +1580,12 @@ toStreamKWith liftio Array{..} = go arrStart
15801580 in liftio elemM `K.consM` go (INDEX_NEXT(p,a))
15811581
15821582{-# INLINE toStreamK #-}
1583−toStreamK :: forall m a. (MonadIO m, Storable a) => Array a -> K.Stream m a
1583+toStreamK :: forall m a. (MonadIO m, Unboxed a) => Array a -> K.Stream m a
15841584toStreamK = toStreamKWith liftIO
15851585
15861586{-# INLINE_NORMAL toStreamDRevWith #-}
15871587toStreamDRevWith ::
1588− forall m a. (Monad m, Storable a)
1588+ forall m a. (Monad m, Unboxed a)
15891589 => (forall b. IO b -> m b) -> Array a -> D.Stream m a
15901590toStreamDRevWith liftio Array{..} =
15911591 let p = INDEX_PREV(aEnd,a)
@@ -1605,12 +1605,12 @@ toStreamDRevWith liftio Array{..} =
16051605--
16061606-- We can try this if the unfold has any perf issues.
16071607{-# INLINE_NORMAL toStreamDRev #-}
1608−toStreamDRev :: forall m a. (MonadIO m, Storable a) => Array a -> D.Stream m a
1608+toStreamDRev :: forall m a. (MonadIO m, Unboxed a) => Array a -> D.Stream m a
16091609toStreamDRev = toStreamDRevWith liftIO
16101610
16111611{-# INLINE toStreamKRevWith #-}
16121612toStreamKRevWith ::
1613− forall m a. (Monad m, Storable a)
1613+ forall m a. (Monad m, Unboxed a)
16141614 => (forall b. IO b -> m b) -> Array a -> K.Stream m a
16151615toStreamKRevWith liftio Array {..} =
16161616 let p = INDEX_PREV(aEnd,a)
@@ -1626,7 +1626,7 @@ toStreamKRevWith liftio Array {..} =
16261626 in liftio elemM `K.consM` go (INDEX_PREV(p,a))
16271627
16281628{-# INLINE toStreamKRev #-}
1629−toStreamKRev :: forall m a. (MonadIO m, Storable a) => Array a -> K.Stream m a
1629+toStreamKRev :: forall m a. (MonadIO m, Unboxed a) => Array a -> K.Stream m a
16301630toStreamKRev = toStreamKRevWith liftIO
16311631
16321632-------------------------------------------------------------------------------
@@ -1638,12 +1638,12 @@ toStreamKRev = toStreamKRevWith liftIO
16381638--
16391639-- | Strict left fold of an array.
16401640{-# INLINE_NORMAL foldl' #-}
1641−foldl' :: (MonadIO m, Storable a) => (b -> a -> b) -> b -> Array a -> m b
1641+foldl' :: (MonadIO m, Unboxed a) => (b -> a -> b) -> b -> Array a -> m b
16421642foldl' f z arr = D.foldl' f z $ toStreamD arr
16431643
16441644-- | Right fold of an array.
16451645{-# INLINE_NORMAL foldr #-}
1646−foldr :: (MonadIO m, Storable a) => (a -> b -> b) -> b -> Array a -> m b
1646+foldr :: (MonadIO m, Unboxed a) => (a -> b -> b) -> b -> Array a -> m b
16471647foldr f z arr = D.foldr f z $ toStreamD arr
16481648
16491649-------------------------------------------------------------------------------
@@ -1667,7 +1667,7 @@ foldr f z arr = D.foldr f z $ toStreamD arr
16671667--
16681668-- /Internal/
16691669{-# INLINE_NORMAL appendNUnsafe #-}
1670−appendNUnsafe :: forall m a. (MonadIO m, Storable a) =>
1670+appendNUnsafe :: forall m a. (MonadIO m, Unboxed a) =>
16711671 m (Array a)
16721672 -> Int
16731673 -> Fold m a (Array a)
@@ -1700,7 +1700,7 @@ appendNUnsafe action n =
17001700--
17011701-- /Pre-release/
17021702{-# INLINE_NORMAL appendN #-}
1703−appendN :: forall m a. (MonadIO m, Storable a) =>
1703+appendN :: forall m a. (MonadIO m, Unboxed a) =>
17041704 m (Array a) -> Int -> Fold m a (Array a)
17051705appendN initial n = FL.take n (appendNUnsafe initial n)
17061706
@@ -1715,7 +1715,7 @@ appendN initial n = FL.take n (appendNUnsafe initial n)
17151715--
17161716-- /Pre-release/
17171717{-# INLINE appendWith #-}
1718−appendWith :: forall m a. (MonadIO m, Storable a) =>
1718+appendWith :: forall m a. (MonadIO m, Unboxed a) =>
17191719 (Int -> Int) -> m (Array a) -> Fold m a (Array a)
17201720appendWith sizer = FL.foldlM' (snocWith sizer)
17211721
@@ -1729,7 +1729,7 @@ appendWith sizer = FL.foldlM' (snocWith sizer)
17291729--
17301730-- /Pre-release/
17311731{-# INLINE append #-}
1732−append :: forall m a. (MonadIO m, Storable a) =>
1732+append :: forall m a. (MonadIO m, Unboxed a) =>
17331733 m (Array a) -> Fold m a (Array a)
17341734append = appendWith (* 2)
17351735
@@ -1743,7 +1743,7 @@ append = appendWith (* 2)
17431743--
17441744-- /Pre-release/
17451745{-# INLINE_NORMAL writeNWithUnsafe #-}
1746−writeNWithUnsafe :: forall m a. (MonadIO m, Storable a)
1746+writeNWithUnsafe :: forall m a. (MonadIO m, Unboxed a)
17471747 => (Int -> m (Array a)) -> Int -> Fold m a (Array a)
17481748writeNWithUnsafe alloc n = fromArrayUnsafe <$> FL.foldlM' step initial
17491749
@@ -1766,7 +1766,7 @@ writeNWithUnsafe alloc n = fromArrayUnsafe <$> FL.foldlM' step initial
17661766--
17671767-- @since 0.7.0
17681768{-# INLINE_NORMAL writeNUnsafe #-}
1769−writeNUnsafe :: forall m a. (MonadIO m, Storable a)
1769+writeNUnsafe :: forall m a. (MonadIO m, Unboxed a)
17701770 => Int -> Fold m a (Array a)
17711771writeNUnsafe = writeNWithUnsafe newArray
17721772
@@ -1777,7 +1777,7 @@ writeNUnsafe = writeNWithUnsafe newArray
17771777-- >>> writeNWith alloc n = Array.appendN (alloc n) n
17781778--
17791779{-# INLINE_NORMAL writeNWith #-}
1780−writeNWith :: forall m a. (MonadIO m, Storable a)
1780+writeNWith :: forall m a. (MonadIO m, Unboxed a)
17811781 => (Int -> m (Array a)) -> Int -> Fold m a (Array a)
17821782writeNWith alloc n = FL.take n (writeNWithUnsafe alloc n)
17831783
@@ -1790,14 +1790,14 @@ writeNWith alloc n = FL.take n (writeNWithUnsafe alloc n)
17901790--
17911791-- @since 0.7.0
17921792{-# INLINE_NORMAL writeN #-}
1793−writeN :: forall m a. (MonadIO m, Storable a) => Int -> Fold m a (Array a)
1793+writeN :: forall m a. (MonadIO m, Unboxed a) => Int -> Fold m a (Array a)
17941794writeN = writeNWith newArray
17951795
17961796-- | Like writeNWithUnsafe but writes the array in reverse order.
17971797--
17981798-- /Internal/
17991799{-# INLINE_NORMAL writeRevNWithUnsafe #-}
1800−writeRevNWithUnsafe :: forall m a. (MonadIO m, Storable a)
1800+writeRevNWithUnsafe :: forall m a. (MonadIO m, Unboxed a)
18011801 => (Int -> m (Array a)) -> Int -> Fold m a (Array a)
18021802writeRevNWithUnsafe alloc n = fromArrayUnsafe <$> FL.foldlM' step initial
18031803
@@ -1818,7 +1818,7 @@ writeRevNWithUnsafe alloc n = fromArrayUnsafe <$> FL.foldlM' step initial
18181818--
18191819-- /Internal/
18201820{-# INLINE_NORMAL writeRevNWith #-}
1821−writeRevNWith :: forall m a. (MonadIO m, Storable a)
1821+writeRevNWith :: forall m a. (MonadIO m, Unboxed a)
18221822 => (Int -> m (Array a)) -> Int -> Fold m a (Array a)
18231823writeRevNWith alloc n = FL.take n (writeRevNWithUnsafe alloc n)
18241824
@@ -1826,7 +1826,7 @@ writeRevNWith alloc n = FL.take n (writeRevNWithUnsafe alloc n)
18261826--
18271827-- /Pre-release/
18281828{-# INLINE_NORMAL writeRevN #-}
1829−writeRevN :: forall m a. (MonadIO m, Storable a) => Int -> Fold m a (Array a)
1829+writeRevN :: forall m a. (MonadIO m, Unboxed a) => Int -> Fold m a (Array a)
18301830writeRevN = writeRevNWith newArray
18311831
18321832-- | @writeNAligned align n@ folds a maximum of @n@ elements from the input
@@ -1838,7 +1838,7 @@ writeRevN = writeRevNWith newArray
18381838-- /Pre-release/
18391839--
18401840{-# INLINE_NORMAL writeNAligned #-}
1841−writeNAligned :: forall m a. (MonadIO m, Storable a)
1841+writeNAligned :: forall m a. (MonadIO m, Unboxed a)
18421842 => Int -> Int -> Fold m a (Array a)
18431843writeNAligned align = writeNWith (newArrayAligned align)
18441844
@@ -1856,7 +1856,7 @@ writeNAligned align = writeNWith (newArrayAligned align)
18561856-- /Unimplemented/
18571857--
18581858{-# INLINE_NORMAL writeChunks #-}
1859−writeChunks :: (MonadIO m, Storable a) =>
1859+writeChunks :: (MonadIO m, Unboxed a) =>
18601860 Int -> Fold m a (K.Stream n (Array a))
18611861writeChunks n = FL.many (writeN n) FL.toStreamK
18621862
@@ -1889,7 +1889,7 @@ writeChunks n = FL.many (writeN n) FL.toStreamK
18891889--
18901890-- /Pre-release/
18911891{-# INLINE_NORMAL writeWith #-}
1892−writeWith :: forall m a. (MonadIO m, Storable a)
1892+writeWith :: forall m a. (MonadIO m, Unboxed a)
18931893 => Int -> Fold m a (Array a)
18941894-- writeWith n = FL.rmapM rightSize $ appendWith (* 2) (newArray n)
18951895writeWith elemCount =
@@ -1928,7 +1928,7 @@ writeWith elemCount =
19281928--
19291929-- @since 0.7.0
19301930{-# INLINE write #-}
1931−write :: forall m a. (MonadIO m, Storable a) => Fold m a (Array a)
1931+write :: forall m a. (MonadIO m, Unboxed a) => Fold m a (Array a)
19321932write = writeWith (allocBytesToElemCount (undefined :: a) arrayChunkBytes)
19331933
19341934-------------------------------------------------------------------------------
@@ -1940,7 +1940,7 @@ write = writeWith (allocBytesToElemCount (undefined :: a) arrayChunkBytes)
19401940-- >>> fromStreamDN n = StreamD.fold (Array.writeN n)
19411941--
19421942{-# INLINE_NORMAL fromStreamDN #-}
1943−fromStreamDN :: forall m a. (MonadIO m, Storable a)
1943+fromStreamDN :: forall m a. (MonadIO m, Unboxed a)
19441944 => Int -> D.Stream m a -> m (Array a)
19451945-- fromStreamDN n = D.fold (writeN n)
19461946fromStreamDN limit str = do
@@ -1960,14 +1960,14 @@ fromStreamDN limit str = do
19601960--
19611961-- @since 0.7.0
19621962{-# INLINABLE fromListN #-}
1963−fromListN :: (MonadIO m, Storable a) => Int -> [a] -> m (Array a)
1963+fromListN :: (MonadIO m, Unboxed a) => Int -> [a] -> m (Array a)
19641964fromListN n xs = fromStreamDN n $ D.fromList xs
19651965
19661966-- | Like fromListN but writes the array in reverse order.
19671967--
19681968-- /Pre-release/
19691969{-# INLINE fromListRevN #-}
1970−fromListRevN :: (MonadIO m, Storable a) => Int -> [a] -> m (Array a)
1970+fromListRevN :: (MonadIO m, Unboxed a) => Int -> [a] -> m (Array a)
19711971fromListRevN n xs = D.fold (writeRevN n) $ D.fromList xs
19721972
19731973-------------------------------------------------------------------------------
@@ -1975,14 +1975,14 @@ fromListRevN n xs = D.fold (writeRevN n) $ D.fromList xs
19751975-------------------------------------------------------------------------------
19761976
19771977{-# INLINE arrayStreamKLength #-}
1978−arrayStreamKLength :: (Monad m, Storable a) => K.Stream m (Array a) -> m Int
1978+arrayStreamKLength :: (Monad m, Unboxed a) => K.Stream m (Array a) -> m Int
19791979arrayStreamKLength as = K.foldl' (+) 0 (K.map length as)
19801980
19811981-- | Convert an array stream to an array. Note that this requires peak memory
19821982-- that is double the size of the array stream.
19831983--
19841984{-# INLINE fromArrayStreamK #-}
1985−fromArrayStreamK :: (Storable a, MonadIO m) =>
1985+fromArrayStreamK :: (Unboxed a, MonadIO m) =>
19861986 K.Stream m (Array a) -> m (Array a)
19871987fromArrayStreamK as = do
19881988 len <- arrayStreamKLength as
@@ -2002,14 +2002,14 @@ fromArrayStreamK as = do
20022002-- >>> fromStreamD = StreamD.fold Array.write
20032003--
20042004{-# INLINE fromStreamD #-}
2005−fromStreamD :: (MonadIO m, Storable a) => D.Stream m a -> m (Array a)
2005+fromStreamD :: (MonadIO m, Unboxed a) => D.Stream m a -> m (Array a)
20062006fromStreamD m = arrayStreamKFromStreamD m >>= fromArrayStreamK
20072007
20082008-- | Create an 'Array' from a list. The list must be of finite size.
20092009--
20102010-- @since 0.7.0
20112011{-# INLINE fromList #-}
2012−fromList :: (MonadIO m, Storable a) => [a] -> m (Array a)
2012+fromList :: (MonadIO m, Unboxed a) => [a] -> m (Array a)
20132013fromList xs = fromStreamD $ D.fromList xs
20142014
20152015-- XXX We are materializing the whole list first for getting the length. Check
@@ -2017,7 +2017,7 @@ fromList xs = fromStreamD $ D.fromList xs
20172017
20182018-- | Like 'fromList' but writes the contents of the list in reverse order.
20192019{-# INLINE fromListRev #-}
2020−fromListRev :: (MonadIO m, Storable a) => [a] -> m (Array a)
2020+fromListRev :: (MonadIO m, Unboxed a) => [a] -> m (Array a)
20212021fromListRev xs = fromListRevN (Prelude.length xs) xs
20222022
20232023-------------------------------------------------------------------------------
@@ -2042,7 +2042,7 @@ putSliceUnsafe src srcStartBytes dst dstStartBytes lenBytes = liftIO $ do
20422042
20432043-- | Copy two arrays into a newly allocated array.
20442044{-# INLINE spliceCopy #-}
2045−spliceCopy :: forall m a. (MonadIO m, Storable a) =>
2045+spliceCopy :: forall m a. (MonadIO m, Unboxed a) =>
20462046 Array a -> Array a -> m (Array a)
20472047spliceCopy arr1 arr2 = liftIO $ do
20482048 let start1 = arrStart arr1
@@ -2084,7 +2084,7 @@ spliceUnsafe dst src =
20842084--
20852085-- /Pre-release/
20862086{-# INLINE spliceWith #-}
2087−spliceWith :: forall m a. (MonadIO m, Storable a) =>
2087+spliceWith :: forall m a. (MonadIO m, Unboxed a) =>
20882088 (Int -> Int -> Int) -> Array a -> Array a -> m (Array a)
20892089spliceWith sizer dst@(Array _ start end bound) src = do
20902090{-
@@ -2118,7 +2118,7 @@ spliceWith sizer dst@(Array _ start end bound) src = do
21182118--
21192119-- /Pre-release/
21202120{-# INLINE splice #-}
2121−splice :: (MonadIO m, Storable a) => Array a -> Array a -> m (Array a)
2121+splice :: (MonadIO m, Unboxed a) => Array a -> Array a -> m (Array a)
21222122splice = spliceWith (+)
21232123
21242124-- | Like 'append' but the growth of the array is exponential. Whenever a new
@@ -2132,7 +2132,7 @@ splice = spliceWith (+)
21322132--
21332133-- /Pre-release/
21342134{-# INLINE spliceExp #-}
2135−spliceExp :: (MonadIO m, Storable a) => Array a -> Array a -> m (Array a)
2135+spliceExp :: (MonadIO m, Unboxed a) => Array a -> Array a -> m (Array a)
21362136spliceExp = spliceWith (\l1 l2 -> max (l1 * 2) (l1 + l2))
21372137
21382138-------------------------------------------------------------------------------
@@ -2171,7 +2171,7 @@ breakOn sep arr@Array{..} = asPtrUnsafe arr $ \p -> liftIO $ do
21712171-- specified index @i@ is the first index of the second slice.
21722172--
21732173-- @since 0.7.0
2174−splitAt :: forall a. Storable a => Int -> Array a -> (Array a, Array a)
2174+splitAt :: forall a. Unboxed a => Int -> Array a -> (Array a, Array a)
21752175splitAt i arr@Array{..} =
21762176 let maxIndex = length arr - 1
21772177 in if i < 0
@@ -2208,7 +2208,7 @@ splitAt i arr@Array{..} =
22082208--
22092209castUnsafe ::
22102210#ifdef DEVBUILD
2211− Storable b =>
2211+ Unboxed b =>
22122212#endif
22132213 Array a -> Array b
22142214castUnsafe (Array contents start end bound) =
@@ -2227,7 +2227,7 @@ asBytes = castUnsafe
22272227--
22282228-- /Pre-release/
22292229--
2230−cast :: forall a b. Storable b => Array a -> Maybe (Array b)
2230+cast :: forall a b. Unboxed b => Array a -> Maybe (Array b)
22312231cast arr =
22322232 let len = byteLength arr
22332233 r = len `mod` SIZE_OF(b)
@@ -2316,7 +2316,7 @@ cmp arr1 arr2 =
23162316-- NFData
23172317-------------------------------------------------------------------------------
23182318
2319−-- This is a Storable array, we cannot have unevaluated data in it so this is
2319+-- This is an Unboxed array, we cannot have unevaluated data in it so this is
23202320-- just a no op.
23212321instance NFData (Array a) where
23222322 {-# INLINE rnf #-}
@@ -2330,7 +2330,7 @@ instance NFData1 Array where
23302330--
23312331-- /Pre-release/
23322332{-# INLINE strip #-}
2333−strip :: forall a m. (Storable a, MonadIO m) =>
2333+strip :: forall a m. (Unboxed a, MonadIO m) =>
23342334 (a -> Bool) -> Array a -> m (Array a)
23352335strip eq arr@Array{..} = liftIO $ do
23362336 st <- getStart arrStart
@@ -2374,7 +2374,7 @@ strip eq arr@Array{..} = liftIO $ do
23742374--
23752375-- /Pre-release/
23762376{-# INLINE bubble #-}
2377−bubble :: (MonadIO m, Storable a) => (a -> a -> Ordering) -> Array a -> m ()
2377+bubble :: (MonadIO m, Unboxed a) => (a -> a -> Ordering) -> Array a -> m ()
23782378bubble cmp0 arr =
23792379 when (l > 1) $ do
23802380 x <- getIndexUnsafe (l - 1) arr
core/src/Streamly/Internal/Data/Array/Unboxed/Type.hs+47−47
@@ -89,7 +89,7 @@ import GHC.Ptr (Ptr(..))
8989import Streamly.Internal.Data.Array.Unboxed.Mut.Type (ArrayContents)
9090import Streamly.Internal.Data.Fold.Type (Fold(..))
9191import Streamly.Internal.Data.Stream.Type (Stream)
92−import Streamly.Internal.Data.Unboxed (Storable, peekWith, sizeOf)
92+import Streamly.Internal.Data.Unboxed (Unboxed, peekWith, sizeOf)
9393import Streamly.Internal.Data.Unfold.Type (Unfold(..))
9494import Text.Read (readPrec, readListPrec, readListPrecDefault)
9595
@@ -125,7 +125,7 @@ import qualified Data.Foldable as F
125125
126126-- $arrayNotes
127127--
128−-- We can use a 'Storable' constraint in the Array type and the constraint can
128+-- We can use an 'Unboxed' constraint in the Array type and the constraint can
129129-- be automatically provided to a function that pattern matches on the Array
130130-- type. However, it has huge performance cost, so we do not use it.
131131-- Investigate a GHC improvement possiblity.
@@ -134,7 +134,7 @@ import qualified Data.Foldable as F
134134--
135135data Array a =
136136#ifdef DEVBUILD
137− Storable a =>
137+ Unboxed a =>
138138#endif
139139 -- All offsets are in terms of bytes from the start of arraycontents
140140 Array
@@ -182,7 +182,7 @@ unsafeFreeze (MA.Array ac as ae _) = Array ac as ae
182182-- | Similar to 'unsafeFreeze' but uses 'MA.rightSize' on the mutable array
183183-- first.
184184{-# INLINE unsafeFreezeWithShrink #-}
185−unsafeFreezeWithShrink :: Storable a => MA.Array a -> Array a
185+unsafeFreezeWithShrink :: Unboxed a => MA.Array a -> Array a
186186unsafeFreezeWithShrink arr = unsafePerformIO $ do
187187 MA.Array ac as ae _ <- MA.rightSize arr
188188 return $ Array ac as ae
@@ -217,7 +217,7 @@ unpin = fmap unsafeFreeze . MA.unpin . unsafeThaw
217217
218218-- Splice two immutable arrays creating a new array.
219219{-# INLINE splice #-}
220−splice :: (MonadIO m, Storable a) => Array a -> Array a -> m (Array a)
220+splice :: (MonadIO m, Unboxed a) => Array a -> Array a -> m (Array a)
221221splice arr1 arr2 =
222222 unsafeFreeze <$> MA.splice (unsafeThaw arr1) (unsafeThaw arr2)
223223
@@ -229,7 +229,7 @@ splice arr1 arr2 =
229229--
230230-- @since 0.8.0
231231{-# INLINABLE fromListN #-}
232−fromListN :: Storable a => Int -> [a] -> Array a
232+fromListN :: Unboxed a => Int -> [a] -> Array a
233233fromListN n xs = unsafePerformIO $ unsafeFreeze <$> MA.fromListN n xs
234234
235235-- | Create an 'Array' from the first N elements of a list in reverse order.
@@ -238,7 +238,7 @@ fromListN n xs = unsafePerformIO $ unsafeFreeze <$> MA.fromListN n xs
238238--
239239-- /Pre-release/
240240{-# INLINABLE fromListRevN #-}
241−fromListRevN :: Storable a => Int -> [a] -> Array a
241+fromListRevN :: Unboxed a => Int -> [a] -> Array a
242242fromListRevN n xs = unsafePerformIO $ unsafeFreeze <$> MA.fromListRevN n xs
243243
244244-- | Create an 'Array' from a list. The list must be of finite size.
@@ -247,7 +247,7 @@ fromListRevN n xs = unsafePerformIO $ unsafeFreeze <$> MA.fromListRevN n xs
247247--
248248-- @since 0.8.0
249249{-# INLINE fromList #-}
250−fromList :: Storable a => [a] -> Array a
250+fromList :: Unboxed a => [a] -> Array a
251251fromList xs = unsafePerformIO $ unsafeFreeze <$> MA.fromList xs
252252
253253-- | Create an 'Array' from a list in reverse order. The list must be of finite
@@ -255,16 +255,16 @@ fromList xs = unsafePerformIO $ unsafeFreeze <$> MA.fromList xs
255255--
256256-- /Pre-release/
257257{-# INLINABLE fromListRev #-}
258−fromListRev :: Storable a => [a] -> Array a
258+fromListRev :: Unboxed a => [a] -> Array a
259259fromListRev xs = unsafePerformIO $ unsafeFreeze <$> MA.fromListRev xs
260260
261261{-# INLINE_NORMAL fromStreamDN #-}
262−fromStreamDN :: forall m a. (MonadIO m, Storable a)
262+fromStreamDN :: forall m a. (MonadIO m, Unboxed a)
263263 => Int -> D.Stream m a -> m (Array a)
264264fromStreamDN limit str = unsafeFreeze <$> MA.fromStreamDN limit str
265265
266266{-# INLINE_NORMAL fromStreamD #-}
267−fromStreamD :: forall m a. (MonadIO m, Storable a)
267+fromStreamD :: forall m a. (MonadIO m, Unboxed a)
268268 => D.Stream m a -> m (Array a)
269269fromStreamD str = unsafeFreeze <$> MA.fromStreamD str
270270
@@ -273,14 +273,14 @@ fromStreamD str = unsafeFreeze <$> MA.fromStreamD str
273273-------------------------------------------------------------------------------
274274
275275{-# INLINE bufferChunks #-}
276−bufferChunks :: (MonadIO m, Storable a) =>
276+bufferChunks :: (MonadIO m, Unboxed a) =>
277277 D.Stream m a -> m (K.Stream m (Array a))
278278bufferChunks m = D.foldr K.cons K.nil $ arraysOf defaultChunkSize m
279279
280280-- | @arraysOf n stream@ groups the input stream into a stream of
281281-- arrays of size n.
282282{-# INLINE_NORMAL arraysOf #-}
283−arraysOf :: forall m a. (MonadIO m, Storable a)
283+arraysOf :: forall m a. (MonadIO m, Unboxed a)
284284 => Int -> D.Stream m a -> D.Stream m (Array a)
285285arraysOf n str = D.map unsafeFreeze $ MA.arraysOf n str
286286
@@ -291,7 +291,7 @@ arraysOf n str = D.map unsafeFreeze $ MA.arraysOf n str
291291-- We can try this if there are any fusion issues in the unfold.
292292--
293293{-# INLINE_NORMAL flattenArrays #-}
294−flattenArrays :: forall m a. (MonadIO m, Storable a)
294+flattenArrays :: forall m a. (MonadIO m, Unboxed a)
295295 => D.Stream m (Array a) -> D.Stream m a
296296flattenArrays = MA.flattenArrays . D.map unsafeThaw
297297
@@ -302,7 +302,7 @@ flattenArrays = MA.flattenArrays . D.map unsafeThaw
302302-- We can try this if there are any fusion issues in the unfold.
303303--
304304{-# INLINE_NORMAL flattenArraysRev #-}
305−flattenArraysRev :: forall m a. (MonadIO m, Storable a)
305+flattenArraysRev :: forall m a. (MonadIO m, Unboxed a)
306306 => D.Stream m (Array a) -> D.Stream m a
307307flattenArraysRev = MA.flattenArraysRev . D.map unsafeThaw
308308
@@ -322,12 +322,12 @@ breakOn sep arr = do
322322--
323323-- Unsafe because it does not check the bounds of the array.
324324{-# INLINE_NORMAL unsafeIndexIO #-}
325−unsafeIndexIO :: forall a. Storable a => Int -> Array a -> IO a
325+unsafeIndexIO :: forall a. Unboxed a => Int -> Array a -> IO a
326326unsafeIndexIO i arr = MA.getIndexUnsafe i (unsafeThaw arr)
327327
328328-- | Return element at the specified index without checking the bounds.
329329{-# INLINE_NORMAL unsafeIndex #-}
330−unsafeIndex :: forall a. Storable a => Int -> Array a -> a
330+unsafeIndex :: forall a. Unboxed a => Int -> Array a -> a
331331unsafeIndex i arr = let !r = unsafeInlineIO $ unsafeIndexIO i arr in r
332332
333333-- | /O(1)/ Get the byte length of the array.
@@ -344,31 +344,31 @@ byteLength = MA.byteLength . unsafeThaw
344344--
345345-- @since 0.8.0
346346{-# INLINE length #-}
347−length :: Storable a => Array a -> Int
347+length :: Unboxed a => Array a -> Int
348348length arr = MA.length (unsafeThaw arr)
349349
350350-- | Unfold an array into a stream in reverse order.
351351--
352352-- @since 0.8.0
353353{-# INLINE_NORMAL readRev #-}
354−readRev :: forall m a. (Monad m, Storable a) => Unfold m (Array a) a
354+readRev :: forall m a. (Monad m, Unboxed a) => Unfold m (Array a) a
355355readRev = Unfold.lmap unsafeThaw $ MA.readRevWith (return . unsafeInlineIO)
356356
357357{-# INLINE_NORMAL toStreamD #-}
358−toStreamD :: forall m a. (Monad m, Storable a) => Array a -> D.Stream m a
358+toStreamD :: forall m a. (Monad m, Unboxed a) => Array a -> D.Stream m a
359359toStreamD arr = MA.toStreamDWith (return . unsafeInlineIO) (unsafeThaw arr)
360360
361361{-# INLINE toStreamK #-}
362−toStreamK :: forall m a. (Monad m, Storable a) => Array a -> K.Stream m a
362+toStreamK :: forall m a. (Monad m, Unboxed a) => Array a -> K.Stream m a
363363toStreamK arr = MA.toStreamKWith (return . unsafeInlineIO) (unsafeThaw arr)
364364
365365{-# INLINE_NORMAL toStreamDRev #-}
366−toStreamDRev :: forall m a. (Monad m, Storable a) => Array a -> D.Stream m a
366+toStreamDRev :: forall m a. (Monad m, Unboxed a) => Array a -> D.Stream m a
367367toStreamDRev arr =
368368 MA.toStreamDRevWith (return . unsafeInlineIO) (unsafeThaw arr)
369369
370370{-# INLINE toStreamKRev #-}
371−toStreamKRev :: forall m a. (Monad m, Storable a) => Array a -> K.Stream m a
371+toStreamKRev :: forall m a. (Monad m, Unboxed a) => Array a -> K.Stream m a
372372toStreamKRev arr =
373373 MA.toStreamKRevWith (return . unsafeInlineIO) (unsafeThaw arr)
374374
@@ -376,7 +376,7 @@ toStreamKRev arr =
376376--
377377-- /Pre-release/
378378{-# INLINE_EARLY toStream #-}
379−toStream :: (Monad m, Storable a) => Array a -> Stream m a
379+toStream :: (Monad m, Unboxed a) => Array a -> Stream m a
380380toStream = Stream.fromStreamD . toStreamD
381381-- XXX add fallback to StreamK rule
382382-- {-# RULES "Streamly.Array.read fallback to StreamK" [1]
@@ -386,7 +386,7 @@ toStream = Stream.fromStreamD . toStreamD
386386--
387387-- /Pre-release/
388388{-# INLINE_EARLY toStreamRev #-}
389−toStreamRev :: (Monad m, Storable a) => Array a -> Stream m a
389+toStreamRev :: (Monad m, Unboxed a) => Array a -> Stream m a
390390toStreamRev = Stream.fromStreamD . toStreamDRev
391391
392392-- XXX add fallback to StreamK rule
@@ -394,18 +394,18 @@ toStreamRev = Stream.fromStreamD . toStreamDRev
394394-- forall a. S.toStreamK (readRev a) = K.revFromArray a #-}
395395
396396{-# INLINE_NORMAL foldl' #-}
397−foldl' :: forall a b. Storable a => (b -> a -> b) -> b -> Array a -> b
397+foldl' :: forall a b. Unboxed a => (b -> a -> b) -> b -> Array a -> b
398398foldl' f z arr = runIdentity $ D.foldl' f z $ toStreamD arr
399399
400400{-# INLINE_NORMAL foldr #-}
401−foldr :: Storable a => (a -> b -> b) -> b -> Array a -> b
401+foldr :: Unboxed a => (a -> b -> b) -> b -> Array a -> b
402402foldr f z arr = runIdentity $ D.foldr f z $ toStreamD arr
403403
404404-- | Create two slices of an array without copying the original array. The
405405-- specified index @i@ is the first index of the second slice.
406406--
407407-- @since 0.7.0
408−splitAt :: Storable a => Int -> Array a -> (Array a, Array a)
408+splitAt :: Unboxed a => Int -> Array a -> (Array a, Array a)
409409splitAt i arr = (unsafeFreeze a, unsafeFreeze b)
410410 where
411411 (a, b) = MA.splitAt i (unsafeThaw arr)
@@ -413,7 +413,7 @@ splitAt i arr = (unsafeFreeze a, unsafeFreeze b)
413413-- Use foldr/build fusion to fuse with list consumers
414414-- This can be useful when using the IsList instance
415415{-# INLINE_LATE toListFB #-}
416−toListFB :: forall a b. Storable a => (a -> b -> b) -> b -> Array a -> b
416+toListFB :: forall a b. Unboxed a => (a -> b -> b) -> b -> Array a -> b
417417toListFB c n Array{..} = go arrStart
418418 where
419419
@@ -434,7 +434,7 @@ toListFB c n Array{..} = go arrStart
434434--
435435-- @since 0.8.0
436436{-# INLINE toList #-}
437−toList :: Storable a => Array a -> [a]
437+toList :: Unboxed a => Array a -> [a]
438438toList s = build (\c n -> toListFB c n s)
439439
440440-------------------------------------------------------------------------------
@@ -448,7 +448,7 @@ toList s = build (\c n -> toListFB c n s)
448448--
449449-- @since 0.8.0
450450{-# INLINE_NORMAL writeN #-}
451−writeN :: forall m a. (MonadIO m, Storable a) => Int -> Fold m a (Array a)
451+writeN :: forall m a. (MonadIO m, Unboxed a) => Int -> Fold m a (Array a)
452452writeN = fmap unsafeFreeze . MA.writeN
453453
454454-- | @writeNAligned alignment n@ folds a maximum of @n@ elements from the input
@@ -457,7 +457,7 @@ writeN = fmap unsafeFreeze . MA.writeN
457457-- /Pre-release/
458458--
459459{-# INLINE_NORMAL writeNAligned #-}
460−writeNAligned :: forall m a. (MonadIO m, Storable a)
460+writeNAligned :: forall m a. (MonadIO m, Unboxed a)
461461 => Int -> Int -> Fold m a (Array a)
462462writeNAligned alignSize = fmap unsafeFreeze . MA.writeNAligned alignSize
463463
@@ -469,12 +469,12 @@ writeNAligned alignSize = fmap unsafeFreeze . MA.writeNAligned alignSize
469469--
470470-- @since 0.7.0
471471{-# INLINE_NORMAL writeNUnsafe #-}
472−writeNUnsafe :: forall m a. (MonadIO m, Storable a)
472+writeNUnsafe :: forall m a. (MonadIO m, Unboxed a)
473473 => Int -> Fold m a (Array a)
474474writeNUnsafe n = unsafeFreeze <$> MA.writeNUnsafe n
475475
476476{-# INLINE_NORMAL writeWith #-}
477−writeWith :: forall m a. (MonadIO m, Storable a)
477+writeWith :: forall m a. (MonadIO m, Unboxed a)
478478 => Int -> Fold m a (Array a)
479479-- writeWith n = FL.rmapM spliceArrays $ toArraysOf n
480480writeWith elemCount = unsafeFreeze <$> MA.writeWith elemCount
@@ -487,18 +487,18 @@ writeWith elemCount = unsafeFreeze <$> MA.writeWith elemCount
487487--
488488-- @since 0.8.0
489489{-# INLINE write #-}
490−write :: forall m a. (MonadIO m, Storable a) => Fold m a (Array a)
490+write :: forall m a. (MonadIO m, Unboxed a) => Fold m a (Array a)
491491write = fmap unsafeFreeze MA.write
492492
493493-------------------------------------------------------------------------------
494494-- Instances
495495-------------------------------------------------------------------------------
496496
497−instance (Show a, Storable a) => Show (Array a) where
497+instance (Show a, Unboxed a) => Show (Array a) where
498498 {-# INLINE showsPrec #-}
499499 showsPrec _ = shows . toList
500500
501−instance (Storable a, Read a, Show a) => Read (Array a) where
501+instance (Unboxed a, Read a, Show a) => Read (Array a) where
502502 {-# INLINE readPrec #-}
503503 readPrec = fromList <$> readPrec
504504 readListPrec = readListPrecDefault
@@ -508,7 +508,7 @@ instance (a ~ Char) => IsString (Array a) where
508508 fromString = fromList
509509
510510-- GHC versions 8.0 and below cannot derive IsList
511−instance Storable a => IsList (Array a) where
511+instance Unboxed a => IsList (Array a) where
512512 type (Item (Array a)) = a
513513 {-# INLINE fromList #-}
514514 fromList = fromList
@@ -517,14 +517,14 @@ instance Storable a => IsList (Array a) where
517517 {-# INLINE toList #-}
518518 toList = toList
519519
520−-- XXX we are assuming that Storable equality means element equality. This may
520+-- XXX we are assuming that Unboxed equality means element equality. This may
521521-- or may not be correct? arrcmp is 40% faster compared to stream equality.
522−instance (Storable a, Eq a) => Eq (Array a) where
522+instance (Unboxed a, Eq a) => Eq (Array a) where
523523 {-# INLINE (==) #-}
524524 arr1 == arr2 =
525525 (==) EQ $ unsafeInlineIO $! unsafeThaw arr1 `MA.cmp` unsafeThaw arr2
526526
527−-- Since this is a Storable array we cannot have unevaluated data in it so
527+-- Since this is an Unboxed array we cannot have unevaluated data in it so
528528-- this is just a no op.
529529instance NFData (Array a) where
530530 {-# INLINE rnf #-}
@@ -533,7 +533,7 @@ instance NFData (Array a) where
533533instance NFData1 Array where
534534 liftRnf _ Array{} = ()
535535
536−instance (Storable a, Ord a) => Ord (Array a) where
536+instance (Unboxed a, Ord a) => Ord (Array a) where
537537 {-# INLINE compare #-}
538538 compare arr1 arr2 = runIdentity $
539539 D.cmpBy compare (toStreamD arr1) (toStreamD arr2)
@@ -561,7 +561,7 @@ instance (Storable a, Ord a) => Ord (Array a) where
561561 min x y = if x <= y then x else y
562562
563563#ifdef DEVBUILD
564−-- Definitions using the Storable constraint from the Array type. These are to
564+-- Definitions using the Unboxed constraint from the Array type. These are to
565565-- make the Foldable instance possible though it is much slower (7x slower).
566566--
567567{-# INLINE_NORMAL toStreamD_ #-}
@@ -578,7 +578,7 @@ toStreamD_ size Array{..} = D.Stream step arrStart
578578
579579{-
580580
581−XXX Why isn't Storable implicit? This does not compile unless I use the Storable
581+XXX Why isn't Unboxed implicit? This does not compile unless I use the Unboxed
582582contraint.
583583
584584{-# INLINE_NORMAL _foldr #-}
@@ -599,16 +599,16 @@ instance Foldable Array where
599599-- Semigroup and Monoid
600600-------------------------------------------------------------------------------
601601
602−instance Storable a => Semigroup (Array a) where
602+instance Unboxed a => Semigroup (Array a) where
603603 arr1 <> arr2 = unsafePerformIO $ splice arr1 arr2
604604
605605nil ::
606606#ifdef DEVBUILD
607− Storable a =>
607+ Unboxed a =>
608608#endif
609609 Array a
610610nil = Array MA.nilArrayContents 0 0
611611
612−instance Storable a => Monoid (Array a) where
612+instance Unboxed a => Monoid (Array a) where
613613 mempty = nil
614614 mappend = (<>)
core/src/Streamly/Internal/Data/Stream/Bottom.hs+2−2
@@ -55,7 +55,7 @@ where
5555
5656import Control.Monad.IO.Class (MonadIO(..))
5757import Streamly.Internal.Data.Fold.Type (Fold (..))
58−import Streamly.Internal.Data.Unboxed (Storable)
58+import Streamly.Internal.Data.Unboxed (Unboxed)
5959import Streamly.Internal.System.IO (defaultChunkSize)
6060
6161import qualified Streamly.Internal.Data.Array.Unboxed.Type as A
@@ -312,7 +312,7 @@ reverse s = fromStreamD $ D.reverse $ toStreamD s
312312--
313313-- /Pre-release/
314314{-# INLINE reverse' #-}
315−reverse' :: (MonadIO m, Storable a) => Stream m a -> Stream m a
315+reverse' :: (MonadIO m, Unboxed a) => Stream m a -> Stream m a
316316-- reverse' s = fromStreamD $ D.reverse' $ toStreamD s
317317reverse' =
318318 fromStreamD
core/src/Streamly/Internal/Data/Stream/Reduce.hs+2−2
@@ -58,7 +58,7 @@ import Streamly.Internal.Data.Parser (Parser (..))
5858import Streamly.Internal.Data.Refold.Type (Refold (..))
5959import Streamly.Internal.Data.Stream.Bottom (foldManyPost)
6060import Streamly.Internal.Data.Stream.Type (Stream, fromStreamD, toStreamD)
61−import Streamly.Internal.Data.Unboxed (Storable)
61+import Streamly.Internal.Data.Unboxed (Unboxed)
6262
6363import qualified Streamly.Internal.Data.Array.Unboxed.Type as Array
6464import qualified Streamly.Internal.Data.Parser.ParserD as ParserD
@@ -313,6 +313,6 @@ parseIterate f i m = fromStreamD $
313313--
314314-- /Pre-release/
315315{-# INLINE arraysOf #-}
316−arraysOf :: (MonadIO m, Storable a)
316+arraysOf :: (MonadIO m, Unboxed a)
317317 => Int -> Stream m a -> Stream m (Array a)
318318arraysOf n = fromStreamD . Array.arraysOf n . toStreamD
core/src/Streamly/Internal/Data/Unboxed.hs+1−4
@@ -2,8 +2,7 @@
22{-# LANGUAGE UnboxedTuples #-}
33
44module Streamly.Internal.Data.Unboxed
5− ( Storable
6− , Unboxed
5+ ( Unboxed
76 , alignment
87 , peekWith
98 , pokeWith
@@ -380,8 +379,6 @@ instance forall a. Unboxed a => Unboxed (Complex a) where
380379-- Functions
381380--------------------------------------------------------------------------------
382381
383−type Storable a = Unboxed a
384−
385382{-# INLINE peekWith #-}
386383peekWith :: Unboxed a => ArrayContents a -> Int -> IO a
387384peekWith = readByteArray
src/Streamly/Internal/Data/Array/Stream/Foreign.hs+32−32
@@ -58,7 +58,7 @@ import Control.Monad.IO.Class (MonadIO(..))
5858import Data.Semigroup (Semigroup(..))
5959#endif
6060import Data.Word (Word8)
61−import Streamly.Internal.Data.Unboxed (Storable, peekWith, sizeOf)
61+import Streamly.Internal.Data.Unboxed (Unboxed, peekWith, sizeOf)
6262import Fusion.Plugin.Types (Fuse(..))
6363import GHC.Exts (SpecConstrAnnotation(..))
6464import GHC.Types (SPEC(..))
@@ -105,7 +105,7 @@ import qualified Streamly.Internal.Data.Stream.Type as Stream
105105--
106106-- /Pre-release/
107107{-# INLINE arraysOf #-}
108−arraysOf :: (IsStream t, MonadIO m, Storable a)
108+arraysOf :: (IsStream t, MonadIO m, Unboxed a)
109109 => Int -> t m a -> t m (Array a)
110110arraysOf n str = fromStreamD $ A.arraysOf n (toStreamD str)
111111
@@ -125,7 +125,7 @@ arraysOf n str = fromStreamD $ A.arraysOf n (toStreamD str)
125125--
126126-- @since 0.7.0
127127{-# INLINE concat #-}
128−concat :: (IsStream t, Monad m, Storable a) => t m (Array a) -> t m a
128+concat :: (IsStream t, Monad m, Unboxed a) => t m (Array a) -> t m a
129129-- concat m = fromStreamD $ A.flattenArrays (toStreamD m)
130130-- concat m = fromStreamD $ D.concatMap A.toStreamD (toStreamD m)
131131concat m = fromStreamD $ D.unfoldMany A.read (toStreamD m)
@@ -137,7 +137,7 @@ concat m = fromStreamD $ D.unfoldMany A.read (toStreamD m)
137137--
138138-- @since 0.7.0
139139{-# INLINE concatRev #-}
140−concatRev :: (IsStream t, Monad m, Storable a) => t m (Array a) -> t m a
140+concatRev :: (IsStream t, Monad m, Unboxed a) => t m (Array a) -> t m a
141141-- concatRev m = fromStreamD $ A.flattenArraysRev (toStreamD m)
142142concatRev m = fromStreamD $ D.unfoldMany A.readRev (toStreamD m)
143143
@@ -150,11 +150,11 @@ concatRev m = fromStreamD $ D.unfoldMany A.readRev (toStreamD m)
150150--
151151-- /Pre-release/
152152{-# INLINE interpose #-}
153−interpose :: (Monad m, IsStream t, Storable a) => a -> t m (Array a) -> t m a
153+interpose :: (Monad m, IsStream t, Unboxed a) => a -> t m (Array a) -> t m a
154154interpose x = S.interpose x A.read
155155
156156{-# INLINE intercalateSuffix #-}
157−intercalateSuffix :: (Monad m, IsStream t, Storable a)
157+intercalateSuffix :: (Monad m, IsStream t, Unboxed a)
158158 => Array a -> t m (Array a) -> t m a
159159intercalateSuffix = S.intercalateSuffix A.read
160160
@@ -163,7 +163,7 @@ intercalateSuffix = S.intercalateSuffix A.read
163163--
164164-- @since 0.7.0
165165{-# INLINE interposeSuffix #-}
166−interposeSuffix :: (Monad m, IsStream t, Storable a)
166+interposeSuffix :: (Monad m, IsStream t, Unboxed a)
167167 => a -> t m (Array a) -> t m a
168168-- interposeSuffix x = fromStreamD . A.unlines x . toStreamD
169169interposeSuffix x = S.interposeSuffix x A.read
@@ -174,7 +174,7 @@ data FlattenState s a =
174174
175175-- XXX Remove monadIO constraint
176176{-# INLINE_NORMAL unlines #-}
177−unlines :: forall m a. (MonadIO m, Storable a)
177+unlines :: forall m a. (MonadIO m, Unboxed a)
178178 => a -> D.Stream m (Array a) -> D.Stream m a
179179unlines sep (D.Stream step state) = D.Stream step' (OuterLoop state)
180180 where
@@ -202,7 +202,7 @@ unlines sep (D.Stream step state) = D.Stream step' (OuterLoop state)
202202-- module Streamly.Internal.Data.Array.Stream.Mut.Foreign
203203--
204204{-# INLINE_NORMAL packArraysChunksOf #-}
205−packArraysChunksOf :: (MonadIO m, Storable a)
205+packArraysChunksOf :: (MonadIO m, Unboxed a)
206206 => Int -> D.Stream m (Array a) -> D.Stream m (Array a)
207207packArraysChunksOf n str =
208208 D.map A.unsafeFreeze $ AS.packArraysChunksOf n $ D.map A.unsafeThaw str
@@ -210,7 +210,7 @@ packArraysChunksOf n str =
210210-- XXX instead of writing two different versions of this operation, we should
211211-- write it as a pipe.
212212{-# INLINE_NORMAL lpackArraysChunksOf #-}
213−lpackArraysChunksOf :: (MonadIO m, Storable a)
213+lpackArraysChunksOf :: (MonadIO m, Unboxed a)
214214 => Int -> Fold m (Array a) () -> Fold m (Array a) ()
215215lpackArraysChunksOf n fld =
216216 FL.lmap A.unsafeThaw $ AS.lpackArraysChunksOf n (FL.lmap A.unsafeFreeze fld)
@@ -220,7 +220,7 @@ lpackArraysChunksOf n fld =
220220--
221221-- @since 0.7.0
222222{-# INLINE compact #-}
223−compact :: (MonadIO m, Storable a)
223+compact :: (MonadIO m, Unboxed a)
224224 => Int -> SerialT m (Array a) -> SerialT m (Array a)
225225compact n xs = fromStreamD $ packArraysChunksOf n (toStreamD xs)
226226
@@ -317,7 +317,7 @@ splitOnSuffix byte s =
317317-- to the number of times it can be called on the same stream.
318318--
319319{-# INLINE_NORMAL foldBreakD #-}
320−foldBreakD :: forall m a b. (MonadIO m, Storable a) =>
320+foldBreakD :: forall m a b. (MonadIO m, Unboxed a) =>
321321 Fold m a b -> D.Stream m (Array a) -> m (b, D.Stream m (Array a))
322322foldBreakD (Fold fstep initial extract) stream@(D.Stream step state) = do
323323 res <- initial
@@ -353,7 +353,7 @@ foldBreakD (Fold fstep initial extract) stream@(D.Stream step state) = do
353353 FL.Partial fs1 -> goArray SPEC st fp next fs1
354354
355355{-# INLINE_NORMAL foldBreakK #-}
356−foldBreakK :: forall m a b. (MonadIO m, Storable a) =>
356+foldBreakK :: forall m a b. (MonadIO m, Unboxed a) =>
357357 Fold m a b -> K.Stream m (Array a) -> m (b, K.Stream m (Array a))
358358foldBreakK (Fold fstep initial extract) stream = do
359359 res <- initial
@@ -394,7 +394,7 @@ foldBreakK (Fold fstep initial extract) stream = do
394394--
395395{-# INLINE_NORMAL foldBreak #-}
396396foldBreak ::
397− (MonadIO m, Storable a)
397+ (MonadIO m, Unboxed a)
398398 => FL.Fold m a b
399399 -> SerialT m (A.Array a)
400400 -> m (b, SerialT m (A.Array a))
@@ -413,7 +413,7 @@ foldBreak f =
413413
414414-- When we have to take an array partially, take the last part of the array.
415415{-# INLINE takeArrayListRev #-}
416−takeArrayListRev :: forall a. Storable a => Int -> [Array a] -> [Array a]
416+takeArrayListRev :: forall a. Unboxed a => Int -> [Array a] -> [Array a]
417417takeArrayListRev = go
418418
419419 where
@@ -434,7 +434,7 @@ takeArrayListRev = go
434434-- the first split.
435435{-# INLINE splitAtArrayListRev #-}
436436splitAtArrayListRev ::
437− forall a. Storable a => Int -> [Array a] -> ([Array a],[Array a])
437+ forall a. Unboxed a => Int -> [Array a] -> ([Array a],[Array a])
438438splitAtArrayListRev n ls
439439 | n <= 0 = ([], ls)
440440 | otherwise = go n ls
@@ -464,14 +464,14 @@ splitAtArrayListRev n ls
464464-- CAUTION! length must more than equal to lengths of all the arrays in the
465465-- stream.
466466{-# INLINE spliceArraysLenUnsafe #-}
467−spliceArraysLenUnsafe :: (MonadIO m, Storable a)
467+spliceArraysLenUnsafe :: (MonadIO m, Unboxed a)
468468 => Int -> SerialT m (MA.Array a) -> m (MA.Array a)
469469spliceArraysLenUnsafe len buffered = do
470470 arr <- liftIO $ MA.newArray len
471471 S.foldlM' MA.spliceUnsafe (return arr) buffered
472472
473473{-# INLINE _spliceArrays #-}
474−_spliceArrays :: (MonadIO m, Storable a)
474+_spliceArrays :: (MonadIO m, Unboxed a)
475475 => SerialT m (Array a) -> m (Array a)
476476_spliceArrays s = do
477477 buffered <- S.foldr S.cons S.nil s
@@ -485,7 +485,7 @@ _spliceArrays s = do
485485 writeArr dst arr = MA.spliceUnsafe dst (A.unsafeThaw arr)
486486
487487{-# INLINE _spliceArraysBuffered #-}
488−_spliceArraysBuffered :: (MonadIO m, Storable a)
488+_spliceArraysBuffered :: (MonadIO m, Unboxed a)
489489 => SerialT m (Array a) -> m (Array a)
490490_spliceArraysBuffered s = do
491491 buffered <- S.foldr S.cons S.nil s
@@ -493,7 +493,7 @@ _spliceArraysBuffered s = do
493493 A.unsafeFreeze <$> spliceArraysLenUnsafe len (S.map A.unsafeThaw s)
494494
495495{-# INLINE spliceArraysRealloced #-}
496−spliceArraysRealloced :: forall m a. (MonadIO m, Storable a)
496+spliceArraysRealloced :: forall m a. (MonadIO m, Unboxed a)
497497 => SerialT m (Array a) -> m (Array a)
498498spliceArraysRealloced s = do
499499 let n = allocBytesToElemCount (undefined :: a) (4 * 1024)
@@ -509,7 +509,7 @@ spliceArraysRealloced s = do
509509--
510510-- @since 0.7.0
511511{-# INLINE toArray #-}
512−toArray :: (MonadIO m, Storable a) => SerialT m (Array a) -> m (Array a)
512+toArray :: (MonadIO m, Unboxed a) => SerialT m (Array a) -> m (Array a)
513513toArray = spliceArraysRealloced
514514-- spliceArrays = _spliceArraysBuffered
515515
@@ -520,7 +520,7 @@ toArray = spliceArraysRealloced
520520--
521521{-
522522{-# INLINE toArraysInRange #-}
523−toArraysInRange :: (IsStream t, MonadIO m, Storable a)
523+toArraysInRange :: (IsStream t, MonadIO m, Unboxed a)
524524 => Int -> Int -> Fold m (Array a) b -> Fold m a b
525525toArraysInRange low high (Fold step initial extract) =
526526-}
@@ -528,7 +528,7 @@ toArraysInRange low high (Fold step initial extract) =
528528{-
529529-- | Fold the input to a pure buffered stream (List) of arrays.
530530{-# INLINE _toArraysOf #-}
531−_toArraysOf :: (MonadIO m, Storable a)
531+_toArraysOf :: (MonadIO m, Unboxed a)
532532 => Int -> Fold m a (SerialT Identity (Array a))
533533_toArraysOf n = FL.chunksOf n (A.writeNF n) FL.toStream
534534-}
@@ -549,7 +549,7 @@ newtype List a = List {getList :: [a]}
549549-- to the number of times it can be called on the same stream.
550550{-# INLINE_NORMAL parseBreakD #-}
551551parseBreakD ::
552− forall m a b. (MonadIO m, MonadThrow m, Storable a)
552+ forall m a b. (MonadIO m, MonadThrow m, Unboxed a)
553553 => PRD.Parser m a b
554554 -> D.Stream m (Array.Array a)
555555 -> m (b, D.Stream m (Array.Array a))
@@ -629,7 +629,7 @@ parseBreakD
629629
630630{-# INLINE_NORMAL parseBreakK #-}
631631parseBreakK ::
632− forall m a b. (MonadIO m, MonadThrow m, Storable a)
632+ forall m a b. (MonadIO m, MonadThrow m, Unboxed a)
633633 => PRD.Parser m a b
634634 -> K.Stream m (Array.Array a)
635635 -> m (b, K.Stream m (Array.Array a))
@@ -708,7 +708,7 @@ parseBreakK (PRD.Parser pstep initial extract) stream = do
708708--
709709{-# INLINE_NORMAL parseBreak #-}
710710parseBreak ::
711− (MonadIO m, MonadThrow m, Storable a)
711+ (MonadIO m, MonadThrow m, Unboxed a)
712712 => PR.Parser m a b
713713 -> SerialT m (A.Array a)
714714 -> m (b, SerialT m (A.Array a))
@@ -734,7 +734,7 @@ parseBreak p =
734734--
735735{-# INLINE_NORMAL runArrayParserDBreak #-}
736736runArrayParserDBreak ::
737− forall m a b. (MonadIO m, MonadThrow m, Storable a)
737+ forall m a b. (MonadIO m, MonadThrow m, Unboxed a)
738738 => PRD.Parser m (Array a) b
739739 -> D.Stream m (Array.Array a)
740740 -> m (b, D.Stream m (Array.Array a))
@@ -806,7 +806,7 @@ runArrayParserDBreak
806806--
807807{-# INLINE parseArr #-}
808808parseArr ::
809− (MonadIO m, MonadThrow m, Storable a)
809+ (MonadIO m, MonadThrow m, Unboxed a)
810810 => ASF.Parser m a b
811811 -> SerialT m (A.Array a)
812812 -> m (b, SerialT m (A.Array a))
@@ -818,7 +818,7 @@ parseArr p s = fmap fromStreamD <$> parseBreakD p (toStreamD s)
818818-- /Pre-release/
819819--
820820{-# INLINE runArrayFold #-}
821−runArrayFold :: (MonadIO m, MonadThrow m, Storable a) =>
821+runArrayFold :: (MonadIO m, MonadThrow m, Unboxed a) =>
822822 ArrayFold m a b -> SerialT m (A.Array a) -> m b
823823runArrayFold (ArrayFold p) s = fst <$> runArrayParserDBreak p (toStreamD s)
824824
@@ -827,7 +827,7 @@ runArrayFold (ArrayFold p) s = fst <$> runArrayParserDBreak p (toStreamD s)
827827-- /Pre-release/
828828--
829829{-# INLINE runArrayFoldBreak #-}
830−runArrayFoldBreak :: (MonadIO m, MonadThrow m, Storable a) =>
830+runArrayFoldBreak :: (MonadIO m, MonadThrow m, Unboxed a) =>
831831 ArrayFold m a b -> SerialT m (A.Array a) -> m (b, SerialT m (A.Array a))
832832runArrayFoldBreak (ArrayFold p) s =
833833 second fromStreamD <$> runArrayParserDBreak p (toStreamD s)
@@ -842,7 +842,7 @@ data ParseChunksState x inpBuf st pst =
842842
843843{-# INLINE_NORMAL runArrayFoldManyD #-}
844844runArrayFoldManyD
845− :: (MonadThrow m, Storable a)
845+ :: (MonadThrow m, Unboxed a)
846846 => ArrayFold m a b
847847 -> D.Stream m (Array a)
848848 -> D.Stream m b
@@ -970,7 +970,7 @@ runArrayFoldManyD
970970-- /Pre-release/
971971{-# INLINE runArrayFoldMany #-}
972972runArrayFoldMany
973− :: (IsStream t, MonadThrow m, Storable a)
973+ :: (IsStream t, MonadThrow m, Unboxed a)
974974 => ArrayFold m a b
975975 -> t m (Array a)
976976 -> t m b
src/Streamly/Internal/Data/Stream/IsStream/Common.hs+2−2
@@ -79,7 +79,7 @@ import Streamly.Internal.Data.Stream.IsStream.Type
7979import Streamly.Internal.Data.Stream.Serial (SerialT)
8080import Streamly.Internal.Data.Time.Units (AbsTime, RelTime64, addToAbsTime64)
8181import Streamly.Internal.System.IO (defaultChunkSize)
82−import Streamly.Internal.Data.Unboxed (Storable, Unboxed)
82+import Streamly.Internal.Data.Unboxed (Unboxed)
8383
8484import qualified Streamly.Internal.Data.Array.Unboxed.Type as A
8585import qualified Streamly.Internal.Data.Stream.Async as Async
@@ -499,7 +499,7 @@ reverse s = fromStreamS $ S.reverse $ toStreamS s
499499--
500500-- /Pre-release/
501501{-# INLINE reverse' #-}
502−reverse' :: (IsStream t, MonadIO m, Storable a) => t m a -> t m a
502+reverse' :: (IsStream t, MonadIO m, Unboxed a) => t m a -> t m a
503503-- reverse' s = fromStreamD $ D.reverse' $ toStreamD s
504504reverse' =
505505 fromStreamD
src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+7−7
@@ -178,7 +178,7 @@ import Streamly.Internal.Data.Stream.IsStream.Type
178178import Streamly.Internal.Data.Time.Units
179179 ( AbsTime, MilliSecond64(..), addToAbsTime, toRelTime
180180 , toAbsTime)
181−import Streamly.Internal.Data.Unboxed (Storable, Unboxed)
181+import Streamly.Internal.Data.Unboxed (Unboxed)
182182
183183import qualified Data.Heap as H
184184import qualified Streamly.Data.Unfold as Unfold
@@ -779,7 +779,7 @@ splitWithSuffix predicate f = foldMany (FL.takeEndBy predicate f)
779779-- /Unimplemented/
780780--
781781{-# INLINE splitOnAny #-}
782−splitOnAny :: -- (IsStream t, Monad m, Storable a, Integral a) =>
782+splitOnAny :: -- (IsStream t, Monad m, Unboxed a, Integral a) =>
783783 [Array a] -> Fold m a b -> t m a -> t m b
784784splitOnAny _subseq _f _m =
785785 undefined -- D.fromStreamD $ D.splitOnAny f subseq (D.toStreamD m)
@@ -889,7 +889,7 @@ splitOnSuffixSeq patt f m =
889889--
890890-- /Unimplemented/
891891{-# INLINE wordsOn #-}
892−wordsOn :: -- (IsStream t, Monad m, Storable a, Eq a) =>
892+wordsOn :: -- (IsStream t, Monad m, Unboxed a, Eq a) =>
893893 Array a -> Fold m a b -> t m a -> t m b
894894wordsOn _subseq _f _m =
895895 undefined -- D.fromStreamD $ D.wordsOn f subseq (D.toStreamD m)
@@ -939,7 +939,7 @@ splitWithSuffixSeq patt f m =
939939--
940940-- /Unimplemented/
941941{-# INLINE splitOnSuffixSeqAny #-}
942−splitOnSuffixSeqAny :: -- (IsStream t, Monad m, Storable a, Integral a) =>
942+splitOnSuffixSeqAny :: -- (IsStream t, Monad m, Unboxed a, Integral a) =>
943943 [Array a] -> Fold m a b -> t m a -> t m b
944944splitOnSuffixSeqAny _subseq _f _m = undefined
945945 -- D.fromStreamD $ D.splitPostAny f subseq (D.toStreamD m)
@@ -975,7 +975,7 @@ chunksOf n f = fromStreamD . D.chunksOf n f . toStreamD
975975--
976976-- /Pre-release/
977977{-# INLINE arraysOf #-}
978−arraysOf :: (IsStream t, MonadIO m, Storable a)
978+arraysOf :: (IsStream t, MonadIO m, Unboxed a)
979979 => Int -> t m a -> t m (Array a)
980980arraysOf n = fromStreamD . A.arraysOf n . toStreamD
981981
@@ -1081,7 +1081,7 @@ classifySlidingSessions tick interval slide (Fold step initial extract) str
10811081-- insert the new elements, and apply an incremental fold on the sliding
10821082-- window, supplying the outgoing elements, the new ring buffer as arguments.
10831083slidingChunkBuffer
1084− :: (IsStream t, Monad m, Ord a, Storable a)
1084+ :: (IsStream t, Monad m, Ord a, Unboxed a)
10851085 => Int -- window size
10861086 -> Int -- window slide
10871087 -> Fold m (Ring a, Array a) b
@@ -1094,7 +1094,7 @@ slidingChunkBuffer = undefined
10941094-- an incremental fold on the sliding window, supplying the outgoing elements,
10951095-- and the new radix tree buffer as arguments.
10961096slidingSessionBuffer
1097− :: (IsStream t, Monad m, Ord a, Storable a)
1097+ :: (IsStream t, Monad m, Ord a, Unboxed a)
10981098 => Int -- window size
10991099 -> Int -- tick size
11001100 -> Fold m (RTree a, Array a) b
src/Streamly/Internal/FileSystem/FD.hs+15−15
@@ -120,7 +120,7 @@ import Control.Monad.IO.Class (MonadIO(..))
120120import Data.Word (Word8)
121121-- import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
122122import Foreign.Ptr (castPtr)
123−import Streamly.Internal.Data.Unboxed (Storable)
123+import Streamly.Internal.Data.Unboxed (Unboxed)
124124-- import System.IO (Handle, hGetBufSome, hPutBuf)
125125import System.IO (IOMode)
126126import Prelude hiding (read)
@@ -237,7 +237,7 @@ readArrayUpto size (Handle fd) = do
237237--
238238-- @since 0.7.0
239239{-# INLINABLE writeArray #-}
240−writeArray :: Storable a => Handle -> Array a -> IO ()
240+writeArray :: Unboxed a => Handle -> Array a -> IO ()
241241writeArray _ arr | A.length arr == 0 = return ()
242242writeArray (Handle fd) arr =
243243 asPtrUnsafe arr $ \p ->
@@ -334,7 +334,7 @@ readInChunksOf :: (IsStream t, MonadIO m) => Int -> Handle -> t m Word8
334334readInChunksOf chunkSize h = AS.concat $ readArraysOfUpto chunkSize h
335335
336336-- TODO
337−-- read :: (IsStream t, MonadIO m, Storable a) => Handle -> t m a
337+-- read :: (IsStream t, MonadIO m, Unboxed a) => Handle -> t m a
338338--
339339-- > read = 'readByChunks' A.defaultChunkSize
340340-- | Generate a stream of elements of the given type from a file 'Handle'. The
@@ -353,7 +353,7 @@ read = AS.concat . readArrays
353353--
354354-- @since 0.7.0
355355{-# INLINE writeArrays #-}
356−writeArrays :: (MonadIO m, Storable a) => Handle -> Stream m (Array a) -> m ()
356+writeArrays :: (MonadIO m, Unboxed a) => Handle -> Stream m (Array a) -> m ()
357357writeArrays h = S.mapM_ (liftIO . writeArray h)
358358
359359-- | Write a stream of arrays to a handle after coalescing them in chunks of
@@ -363,7 +363,7 @@ writeArrays h = S.mapM_ (liftIO . writeArray h)
363363--
364364-- @since 0.7.0
365365{-# INLINE writeArraysPackedUpto #-}
366−writeArraysPackedUpto :: (MonadIO m, Storable a)
366+writeArraysPackedUpto :: (MonadIO m, Unboxed a)
367367 => Int -> Handle -> Stream m (Array a) -> m ()
368368writeArraysPackedUpto n h xs = writeArrays h $ AS.compact n xs
369369
@@ -422,7 +422,7 @@ write = writeInChunksOf defaultChunkSize
422422
423423{-
424424{-# INLINE write #-}
425−write :: (MonadIO m, Storable a) => Handle -> Stream m a -> m ()
425+write :: (MonadIO m, Unboxed a) => Handle -> Stream m a -> m ()
426426write = toHandleWith A.defaultChunkSize
427427-}
428428
@@ -481,7 +481,7 @@ readLines h f = foldLines (readUtf8 h) f
481481--
482482-- @since 0.7.0
483483{-# INLINE readFrames #-}
484−readFrames :: (IsStream t, MonadIO m, Storable a)
484+readFrames :: (IsStream t, MonadIO m, Unboxed a)
485485 => Array a -> Handle -> Fold m a b -> t m b
486486readFrames = undefined -- foldFrames . read
487487
@@ -490,7 +490,7 @@ readFrames = undefined -- foldFrames . read
490490--
491491-- @since 0.7.0
492492{-# INLINE writeByFrames #-}
493−writeByFrames :: (IsStream t, MonadIO m, Storable a)
493+writeByFrames :: (IsStream t, MonadIO m, Unboxed a)
494494 => Array a -> Handle -> t m a -> m ()
495495writeByFrames = undefined
496496
@@ -508,7 +508,7 @@ writeByFrames = undefined
508508--
509509-- @since 0.7.0
510510{-# INLINE readIndex #-}
511−readIndex :: Storable a => Handle -> Int -> Maybe a
511+readIndex :: Unboxed a => Handle -> Int -> Maybe a
512512readIndex arr i = undefined
513513
514514-- NOTE: To represent a range to read we have chosen (start, size) instead of
@@ -528,7 +528,7 @@ readIndex arr i = undefined
528528-- chunk is aligned with @chunkSize@ from second chunk onwards.
529529--
530530{-# INLINE readSliceWith #-}
531−readSliceWith :: (IsStream t, MonadIO m, Storable a)
531+readSliceWith :: (IsStream t, MonadIO m, Unboxed a)
532532 => Int -> Handle -> Int -> Int -> t m a
533533readSliceWith chunkSize h pos len = undefined
534534
@@ -538,7 +538,7 @@ readSliceWith chunkSize h pos len = undefined
538538--
539539-- @since 0.7.0
540540{-# INLINE readSlice #-}
541−readSlice :: (IsStream t, MonadIO m, Storable a)
541+readSlice :: (IsStream t, MonadIO m, Unboxed a)
542542 => Handle -> Int -> Int -> t m a
543543readSlice = readSliceWith defaultChunkSize
544544
@@ -548,7 +548,7 @@ readSlice = readSliceWith defaultChunkSize
548548--
549549-- @since 0.7.0
550550{-# INLINE readSliceRev #-}
551−readSliceRev :: (IsStream t, MonadIO m, Storable a)
551+readSliceRev :: (IsStream t, MonadIO m, Unboxed a)
552552 => Handle -> Int -> Int -> t m a
553553readSliceRev h i count = undefined
554554
@@ -556,7 +556,7 @@ readSliceRev h i count = undefined
556556--
557557-- @since 0.7.0
558558{-# INLINE writeIndex #-}
559−writeIndex :: (MonadIO m, Storable a) => Handle -> Int -> a -> m ()
559+writeIndex :: (MonadIO m, Unboxed a) => Handle -> Int -> a -> m ()
560560writeIndex h i a = undefined
561561
562562-- | @writeSlice h i count stream@ writes a stream to the file handle @h@
@@ -565,7 +565,7 @@ writeIndex h i a = undefined
565565--
566566-- @since 0.7.0
567567{-# INLINE writeSlice #-}
568−writeSlice :: (IsStream t, Monad m, Storable a)
568+writeSlice :: (IsStream t, Monad m, Unboxed a)
569569 => Handle -> Int -> Int -> t m a -> m ()
570570writeSlice h i len s = undefined
571571
@@ -575,7 +575,7 @@ writeSlice h i len s = undefined
575575--
576576-- @since 0.7.0
577577{-# INLINE writeSliceRev #-}
578−writeSliceRev :: (IsStream t, Monad m, Storable a)
578+writeSliceRev :: (IsStream t, Monad m, Unboxed a)
579579 => Handle -> Int -> Int -> t m a -> m ()
580580writeSliceRev arr i len s = undefined
581581-}
src/Streamly/Internal/FileSystem/Handle.hs+15−15
@@ -114,7 +114,7 @@ import Control.Monad.IO.Class (MonadIO(..))
114114import Data.Function ((&))
115115import Data.Maybe (isNothing, fromJust)
116116import Data.Word (Word8)
117−import Streamly.Internal.Data.Unboxed (Storable)
117+import Streamly.Internal.Data.Unboxed (Unboxed)
118118import System.IO (Handle, SeekMode(..), hGetBufSome, hPutBuf, hSeek)
119119import Prelude hiding (read)
120120
@@ -365,7 +365,7 @@ getBytesWith size h = AS.concat $ getChunksWith size h
365365
366366-- TODO
367367-- Generate a stream of elements of the given type from a file 'Handle'.
368−-- read :: (IsStream t, MonadIO m, Storable a) => Handle -> t m a
368+-- read :: (IsStream t, MonadIO m, Unboxed a) => Handle -> t m a
369369--
370370-- | Unfolds a file handle into a byte stream. IO requests to the device are
371371-- performed in sizes of
@@ -438,7 +438,7 @@ putChunks h = S.mapM_ (putChunk h)
438438--
439439-- @since 0.9.0
440440{-# INLINE putChunksWith #-}
441−putChunksWith :: (MonadIO m, Storable a)
441+putChunksWith :: (MonadIO m, Unboxed a)
442442 => Int -> Handle -> Stream m (Array a) -> m ()
443443putChunksWith n h xs = putChunks h $ AS.compact n xs
444444
@@ -495,7 +495,7 @@ consumeChunks = Refold.drainBy putChunk
495495--
496496-- @since 0.9.0
497497{-# INLINE writeChunksWith #-}
498−writeChunksWith :: (MonadIO m, Storable a)
498+writeChunksWith :: (MonadIO m, Unboxed a)
499499 => Int -> Handle -> Fold m (Array a) ()
500500writeChunksWith n h = lpackArraysChunksOf n (writeChunks h)
501501
@@ -504,7 +504,7 @@ writeChunksWith n h = lpackArraysChunksOf n (writeChunks h)
504504-- @since 0.7.0
505505{-# DEPRECATED writeChunksWithBufferOf "Please use writeChunksWith instead." #-}
506506{-# INLINE writeChunksWithBufferOf #-}
507−writeChunksWithBufferOf :: (MonadIO m, Storable a)
507+writeChunksWithBufferOf :: (MonadIO m, Unboxed a)
508508 => Int -> Handle -> Fold m (Array a) ()
509509writeChunksWithBufferOf = writeChunksWith
510510
@@ -578,7 +578,7 @@ consumer = consumerWith defaultChunkSize
578578
579579{-
580580{-# INLINE write #-}
581−write :: (MonadIO m, Storable a) => Handle -> Stream m a -> m ()
581+write :: (MonadIO m, Unboxed a) => Handle -> Stream m a -> m ()
582582write = toHandleWith A.defaultChunkSize
583583-}
584584
@@ -641,7 +641,7 @@ readLines h f = foldLines (readUtf8 h) f
641641--
642642-- @since 0.7.0
643643{-# INLINE readFrames #-}
644−readFrames :: (IsStream t, MonadIO m, Storable a)
644+readFrames :: (IsStream t, MonadIO m, Unboxed a)
645645 => Array a -> Handle -> Fold m a b -> t m b
646646readFrames = undefined -- foldFrames . read
647647
@@ -650,7 +650,7 @@ readFrames = undefined -- foldFrames . read
650650--
651651-- @since 0.7.0
652652{-# INLINE writeByFrames #-}
653−writeByFrames :: (IsStream t, MonadIO m, Storable a)
653+writeByFrames :: (IsStream t, MonadIO m, Unboxed a)
654654 => Array a -> Handle -> t m a -> m ()
655655writeByFrames = undefined
656656
@@ -685,7 +685,7 @@ writeBySessionsOf n = writeByChunksOrSessionsOf defaultChunkSize n
685685--
686686-- @since 0.7.0
687687{-# INLINE readIndex #-}
688−readIndex :: Storable a => Handle -> Int -> Maybe a
688+readIndex :: Unboxed a => Handle -> Int -> Maybe a
689689readIndex arr i = undefined
690690
691691-- NOTE: To represent a range to read we have chosen (start, size) instead of
@@ -705,7 +705,7 @@ readIndex arr i = undefined
705705-- chunk is aligned with @chunkSize@ from second chunk onwards.
706706--
707707{-# INLINE readSliceWith #-}
708−readSliceWith :: (IsStream t, MonadIO m, Storable a)
708+readSliceWith :: (IsStream t, MonadIO m, Unboxed a)
709709 => Int -> Handle -> Int -> Int -> t m a
710710readSliceWith chunkSize h pos len = undefined
711711
@@ -715,7 +715,7 @@ readSliceWith chunkSize h pos len = undefined
715715--
716716-- @since 0.7.0
717717{-# INLINE readSlice #-}
718−readSlice :: (IsStream t, MonadIO m, Storable a)
718+readSlice :: (IsStream t, MonadIO m, Unboxed a)
719719 => Handle -> Int -> Int -> t m a
720720readSlice = readSliceWith A.defaultChunkSize
721721
@@ -725,7 +725,7 @@ readSlice = readSliceWith A.defaultChunkSize
725725--
726726-- @since 0.7.0
727727{-# INLINE readSliceRev #-}
728−readSliceRev :: (IsStream t, MonadIO m, Storable a)
728+readSliceRev :: (IsStream t, MonadIO m, Unboxed a)
729729 => Handle -> Int -> Int -> t m a
730730readSliceRev h i count = undefined
731731
@@ -733,7 +733,7 @@ readSliceRev h i count = undefined
733733--
734734-- @since 0.7.0
735735{-# INLINE writeIndex #-}
736−writeIndex :: (MonadIO m, Storable a) => Handle -> Int -> a -> m ()
736+writeIndex :: (MonadIO m, Unboxed a) => Handle -> Int -> a -> m ()
737737writeIndex h i a = undefined
738738
739739-- | @writeSlice h i count stream@ writes a stream to the file handle @h@
@@ -742,7 +742,7 @@ writeIndex h i a = undefined
742742--
743743-- @since 0.7.0
744744{-# INLINE writeSlice #-}
745−writeSlice :: (IsStream t, Monad m, Storable a)
745+writeSlice :: (IsStream t, Monad m, Unboxed a)
746746 => Handle -> Int -> Int -> t m a -> m ()
747747writeSlice h i len s = undefined
748748
@@ -752,7 +752,7 @@ writeSlice h i len s = undefined
752752--
753753-- @since 0.7.0
754754{-# INLINE writeSliceRev #-}
755−writeSliceRev :: (IsStream t, Monad m, Storable a)
755+writeSliceRev :: (IsStream t, Monad m, Unboxed a)
756756 => Handle -> Int -> Int -> t m a -> m ()
757757writeSliceRev arr i len s = undefined
758758-}
src/Streamly/Internal/Network/Socket.hs+11−11
@@ -76,7 +76,7 @@ import Control.Monad (forM_, when)
7676import Data.Maybe (isNothing, fromJust)
7777import Data.Word (Word8)
7878import Foreign.Ptr (plusPtr, Ptr, castPtr)
79−import Streamly.Internal.Data.Unboxed (Storable)
79+import Streamly.Internal.Data.Unboxed (Unboxed)
8080import Network.Socket
8181 (Socket, SocketOption(..), Family(..), SockAddr(..),
8282 ProtocolNumber, withSocketsDo, SocketType(..), socket, bind,
@@ -303,7 +303,7 @@ sendAll s p len = do
303303 when (sent >= 0) $ sendAll s (p `plusPtr` sent) (len - sent)
304304
305305{-# INLINABLE writeArrayWith #-}
306−writeArrayWith :: Storable a
306+writeArrayWith :: Unboxed a
307307 => (h -> Ptr Word8 -> Int -> IO ())
308308 -> h
309309 -> Array a
@@ -319,7 +319,7 @@ writeArrayWith f h arr = A.asPtrUnsafe arr $ \ptr -> f h (castPtr ptr) aLen
319319--
320320-- @since 0.8.0
321321{-# INLINABLE writeChunk #-}
322−writeChunk :: Storable a => Socket -> Array a -> IO ()
322+writeChunk :: Unboxed a => Socket -> Array a -> IO ()
323323writeChunk = writeArrayWith sendAll
324324
325325-------------------------------------------------------------------------------
@@ -423,7 +423,7 @@ readWith chunkSize h = A.flattenArrays $ readChunksUpto chunkSize h
423423-}
424424
425425-- TODO
426−-- read :: (IsStream t, MonadIO m, Storable a) => Handle -> t m a
426+-- read :: (IsStream t, MonadIO m, Unboxed a) => Handle -> t m a
427427--
428428-- > read = 'readByChunks' defaultChunkSize
429429-- | Generate a stream of elements of the given type from a socket. The
@@ -467,7 +467,7 @@ read = UF.first defaultChunkSize readWith
467467--
468468-- @since 0.7.0
469469{-# INLINE putChunks #-}
470−putChunks :: (MonadIO m, Storable a)
470+putChunks :: (MonadIO m, Unboxed a)
471471 => Socket -> Stream m (Array a) -> m ()
472472putChunks h = S.mapM_ (liftIO . writeChunk h)
473473
@@ -476,7 +476,7 @@ putChunks h = S.mapM_ (liftIO . writeChunk h)
476476--
477477-- @since 0.7.0
478478{-# INLINE writeChunks #-}
479−writeChunks :: (MonadIO m, Storable a) => Socket -> Fold m (Array a) ()
479+writeChunks :: (MonadIO m, Unboxed a) => Socket -> Fold m (Array a) ()
480480writeChunks h = FL.drainBy (liftIO . writeChunk h)
481481
482482-- | @writeChunksWith bufsize socket@ writes a stream of arrays to
@@ -487,7 +487,7 @@ writeChunks h = FL.drainBy (liftIO . writeChunk h)
487487--
488488-- @since 0.9.0
489489{-# INLINE writeChunksWith #-}
490−writeChunksWith :: (MonadIO m, Storable a)
490+writeChunksWith :: (MonadIO m, Unboxed a)
491491 => Int -> Socket -> Fold m (Array a) ()
492492writeChunksWith n h = lpackArraysChunksOf n (writeChunks h)
493493
@@ -496,7 +496,7 @@ writeChunksWith n h = lpackArraysChunksOf n (writeChunks h)
496496-- @since 0.7.0
497497{-# DEPRECATED writeChunksWithBufferOf "Please use 'writeChunksWith' instead" #-}
498498{-# INLINE writeChunksWithBufferOf #-}
499−writeChunksWithBufferOf :: (MonadIO m, Storable a)
499+writeChunksWithBufferOf :: (MonadIO m, Unboxed a)
500500 => Int -> Socket -> Fold m (Array a) ()
501501writeChunksWithBufferOf = writeChunksWith
502502
@@ -571,7 +571,7 @@ write = writeWith defaultChunkSize
571571
572572{-
573573{-# INLINE write #-}
574−write :: (MonadIO m, Storable a) => Handle -> Stream m a -> m ()
574+write :: (MonadIO m, Unboxed a) => Handle -> Stream m a -> m ()
575575write = toHandleWith defaultChunkSize
576576-}
577577
@@ -630,7 +630,7 @@ readLines h f = foldLines (readUtf8 h) f
630630--
631631-- @since 0.7.0
632632{-# INLINE readFrames #-}
633−readFrames :: (IsStream t, MonadIO m, Storable a)
633+readFrames :: (IsStream t, MonadIO m, Unboxed a)
634634 => Array a -> Handle -> Fold m a b -> t m b
635635readFrames = undefined -- foldFrames . read
636636
@@ -639,7 +639,7 @@ readFrames = undefined -- foldFrames . read
639639--
640640-- @since 0.7.0
641641{-# INLINE writeByFrames #-}
642−writeByFrames :: (IsStream t, MonadIO m, Storable a)
642+writeByFrames :: (IsStream t, MonadIO m, Unboxed a)
643643 => Array a -> Handle -> t m a -> m ()
644644writeByFrames = undefined
645645-}