on master help sign in
Fix dev build
commit05bf4fe4b8de57f47a59cce834a085f6949d9baf authorAdithya Kumar <adithya@composewell.com> dateWed 17 Nov 2021, 02:45 (5 years ago) parentec9c727
4 files changed+23−13
benchmark/Streamly/Benchmark/Data/Array.hs+2 benchmark/Streamly/Benchmark/Data/ArrayOps.hs+4 src/Streamly/Internal/Data/Array/Foreign/Mut/Type.hs+5−1 src/Streamly/Internal/Data/Array/Foreign/Type.hs+12−12
benchmark/Streamly/Benchmark/Data/Array.hs+2
@@ -128,8 +128,10 @@ o_1_space_elimination value =
128128 (S.fold (IA.writeLastN 10)) (P.sourceUnfoldrM value)
129129#if !defined(DATA_ARRAY_PRIM) && !defined(DATA_ARRAY_PRIM_PINNED)
130130#ifdef DEVBUILD
131+{-
131132 , benchPureSink value "foldable/foldl'" Ops.foldableFoldl'
132133 , benchPureSink value "foldable/sum" Ops.foldableSum
134+-}
133135#endif
134136#endif
135137 ]
benchmark/Streamly/Benchmark/Data/ArrayOps.hs+4
@@ -26,7 +26,9 @@ import qualified Streamly.Prelude as S
2626
2727#if !defined(DATA_ARRAY_PRIM) && !defined(DATA_ARRAY_PRIM_PINNED)
2828#ifdef DEVBUILD
29+{-
2930import qualified Data.Foldable as F
31+-}
3032#endif
3133#endif
3234
@@ -210,6 +212,7 @@ readInstance str =
210212 _ -> P.error "readInstance: no parse"
211213
212214#ifdef DEVBUILD
215+{-
213216{-# INLINE foldableFoldl' #-}
214217foldableFoldl' :: Stream Int -> Int
215218foldableFoldl' = F.foldl' (+) 0
@@ -217,6 +220,7 @@ foldableFoldl' = F.foldl' (+) 0
217220{-# INLINE foldableSum #-}
218221foldableSum :: Stream Int -> Int
219222foldableSum = P.sum
223+-}
220224#endif
221225#endif
222226
src/Streamly/Internal/Data/Array/Foreign/Mut/Type.hs+5−1
@@ -1555,7 +1555,11 @@ toArrayUnsafe :: Array a -> ArrayUnsafe a
15551555toArrayUnsafe (Array contents start end _) =
15561556 ArrayUnsafe contents start end
15571557
1558−fromArrayUnsafe :: ArrayUnsafe a -> Array a
1558+fromArrayUnsafe ::
1559+#ifdef DEVBUILD
1560+ Storable a =>
1561+#endif
1562+ ArrayUnsafe a -> Array a
15591563fromArrayUnsafe (ArrayUnsafe contents start end) =
15601564 Array contents start end end
15611565
src/Streamly/Internal/Data/Array/Foreign/Type.hs+12−12
@@ -85,9 +85,6 @@ import Foreign.Storable (Storable(..))
8585import GHC.Base (Addr#, nullAddr#, build)
8686import GHC.Exts (IsList, IsString(..))
8787
88−#ifdef DEVBUILD
89−import GHC.ForeignPtr (touchForeignPtr, unsafeForeignPtrToPtr)
90−#endif
9188import GHC.IO (unsafePerformIO)
9289import GHC.Ptr (Ptr(..))
9390import Streamly.Internal.Data.Array.Foreign.Mut.Type
@@ -742,24 +739,25 @@ instance (Storable a, Ord a) => Ord (Array a) where
742739--
743740{-# INLINE_NORMAL toStreamD_ #-}
744741toStreamD_ :: forall m a. MonadIO m => Int -> Array a -> D.Stream m a
745−toStreamD_ size Array{..} =
746− let p = unsafeForeignPtrToPtr aStart
747− in D.Stream step p
742+toStreamD_ size Array{..} = D.Stream step arrStart
748743
749744 where
750745
751746 {-# INLINE_LATE step #-}
752747 step _ p | p == aEnd = return D.Stop
753− step _ p = do
754− x <- liftIO $ do
755− r <- peek p
756− touchForeignPtr aStart
757− return r
748+ step _ p = liftIO $ do
749+ x <- peek p
750+ touch arrContents
758751 return $ D.Yield x (p `plusPtr` size)
759752
753+{-
754+
755+XXX Why isn't Storable implicit? This does not compile unless I use the Storable
756+contraint.
757+
760758{-# INLINE_NORMAL _foldr #-}
761759_foldr :: forall a b. (a -> b -> b) -> b -> Array a -> b
762−_foldr f z arr@Array {..} =
760+_foldr f z arr =
763761 let !n = sizeOf (undefined :: a)
764762 in unsafePerformIO $ D.foldr f z $ toStreamD_ n arr
765763
@@ -767,6 +765,8 @@ _foldr f z arr@Array {..} =
767765-- operations.
768766instance Foldable Array where
769767 foldr = _foldr
768+
769+-}
770770#endif
771771
772772-------------------------------------------------------------------------------