on master help sign in
Remove Storable aliased to Unboxed
commitdf56bd6abe02c3f59884e568499f39db0a6ed4d9 authorHarendra Kumar <harendra@composewell.com> dateSat 6 Aug 2022, 13:22 (4 years ago) parent2e21c3a
11 files changed+194−197
core/src/Streamly/Internal/Data/Array/Unboxed.hs+11−12 core/src/Streamly/Internal/Data/Array/Unboxed/Mut.hs+4−4 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/Ring/Foreign.hs+1 core/src/Streamly/Internal/Data/Unboxed.hs+1−4 src/Streamly/Internal/Data/Array/Stream/Foreign.hs+2−2 src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+3−3 src/Streamly/Internal/FileSystem/FD.hs+4−4 src/Streamly/Internal/FileSystem/Handle.hs+12−12 src/Streamly/Internal/Network/Socket.hs+3−3
core/src/Streamly/Internal/Data/Array/Unboxed.hs+11−12
@@ -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
@@ -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
@@ -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, Unboxed a, Prim 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− Prim b =>
505+ Unboxed b =>
507506#endif
508507 Array a -> Array b
509508castUnsafe (Array contents start end) =
@@ -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+4−4
@@ -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, Unboxed)
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
@@ -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 Unboxed 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 Unboxed 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/Ring/Foreign.hs+1
@@ -604,6 +604,7 @@ slidingWindowWith n (Fold step1 initial1 extract1) = Fold step initial extract
604604 Done b -> Done b
605605
606606 extract (Tuple4' _ _ _ st) = extract1 st
607+
607608-- | @slidingWindow collector@ is an incremental sliding window
608609-- fold that does not require all the intermediate elements in a computation.
609610-- This maintains @n@ elements in the window, when a new element comes it slides
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+2−2
@@ -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, Unboxed, peekWith, sizeOf)
61+import Streamly.Internal.Data.Unboxed (Unboxed, peekWith, sizeOf)
6262import Fusion.Plugin.Types (Fuse(..))
6363import GHC.Exts (SpecConstrAnnotation(..))
6464import GHC.Types (SPEC(..))
@@ -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
src/Streamly/Internal/Data/Stream/IsStream/Reduce.hs+3−3
@@ -779,7 +779,7 @@ splitWithSuffix predicate f = foldMany (FL.takeEndBy predicate f)
779779-- /Unimplemented/
780780--
781781{-# INLINE splitOnAny #-}
782−splitOnAny :: -- (IsStream t, Monad m, Prim 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, Prim 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, Prim 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)
src/Streamly/Internal/FileSystem/FD.hs+4−4
@@ -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, Unboxed)
123+import Streamly.Internal.Data.Unboxed (Unboxed)
124124-- import System.IO (Handle, hGetBufSome, hPutBuf)
125125import System.IO (IOMode)
126126import Prelude hiding (read)
@@ -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
src/Streamly/Internal/FileSystem/Handle.hs+12−12
@@ -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, Unboxed)
117+import Streamly.Internal.Data.Unboxed (Unboxed)
118118import System.IO (Handle, SeekMode(..), hGetBufSome, hPutBuf, hSeek)
119119import Prelude hiding (read)
120120
@@ -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
@@ -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+3−3
@@ -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, Unboxed)
79+import Streamly.Internal.Data.Unboxed (Unboxed)
8080import Network.Socket
8181 (Socket, SocketOption(..), Family(..), SockAddr(..),
8282 ProtocolNumber, withSocketsDo, SocketType(..), socket, bind,
@@ -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
@@ -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