on master help sign in
Fix dev build
05bf4feAdithya Kumar
benchmark/Streamly/Benchmark/Data/Array.hs+2
@@ -128,8 +128,10 @@ o_1_space_elimination value =
128 (S.fold (IA.writeLastN 10)) (P.sourceUnfoldrM value)
128 (S.fold (IA.writeLastN 10)) (P.sourceUnfoldrM value)
129#if !defined(DATA_ARRAY_PRIM) && !defined(DATA_ARRAY_PRIM_PINNED)
129#if !defined(DATA_ARRAY_PRIM) && !defined(DATA_ARRAY_PRIM_PINNED)
130#ifdef DEVBUILD
130#ifdef DEVBUILD
131+{-
131 , benchPureSink value "foldable/foldl'" Ops.foldableFoldl'
132 , benchPureSink value "foldable/foldl'" Ops.foldableFoldl'
132 , benchPureSink value "foldable/sum" Ops.foldableSum
133 , benchPureSink value "foldable/sum" Ops.foldableSum
134+-}
133#endif
135#endif
134#endif
136#endif
135 ]
137 ]
benchmark/Streamly/Benchmark/Data/ArrayOps.hs+4
@@ -26,7 +26,9 @@ import qualified Streamly.Prelude as S
26
26
27#if !defined(DATA_ARRAY_PRIM) && !defined(DATA_ARRAY_PRIM_PINNED)
27#if !defined(DATA_ARRAY_PRIM) && !defined(DATA_ARRAY_PRIM_PINNED)
28#ifdef DEVBUILD
28#ifdef DEVBUILD
29+{-
29import qualified Data.Foldable as F
30import qualified Data.Foldable as F
31+-}
30#endif
32#endif
31#endif
33#endif
32
34
@@ -210,6 +212,7 @@ readInstance str =
210 _ -> P.error "readInstance: no parse"
212 _ -> P.error "readInstance: no parse"
211
213
212#ifdef DEVBUILD
214#ifdef DEVBUILD
215+{-
213{-# INLINE foldableFoldl' #-}
216{-# INLINE foldableFoldl' #-}
214foldableFoldl' :: Stream Int -> Int
217foldableFoldl' :: Stream Int -> Int
215foldableFoldl' = F.foldl' (+) 0
218foldableFoldl' = F.foldl' (+) 0
@@ -217,6 +220,7 @@ foldableFoldl' = F.foldl' (+) 0
217{-# INLINE foldableSum #-}
220{-# INLINE foldableSum #-}
218foldableSum :: Stream Int -> Int
221foldableSum :: Stream Int -> Int
219foldableSum = P.sum
222foldableSum = P.sum
223+-}
220#endif
224#endif
221#endif
225#endif
222
226
src/Streamly/Internal/Data/Array/Foreign/Mut/Type.hs+5−1
@@ -1555,7 +1555,11 @@ toArrayUnsafe :: Array a -> ArrayUnsafe a
1555toArrayUnsafe (Array contents start end _) =
1555toArrayUnsafe (Array contents start end _) =
1556 ArrayUnsafe contents start end
1556 ArrayUnsafe contents start end
1557
1557
1558+fromArrayUnsafe ::
1559+#ifdef DEVBUILD
1560+ Storable a =>
1561+#endif
1558−fromArrayUnsafe :: ArrayUnsafe a -> Array a
1562+ ArrayUnsafe a -> Array a
1559fromArrayUnsafe (ArrayUnsafe contents start end) =
1563fromArrayUnsafe (ArrayUnsafe contents start end) =
1560 Array contents start end end
1564 Array contents start end end
1561
1565
src/Streamly/Internal/Data/Array/Foreign/Type.hs+12−12
@@ -85,9 +85,6 @@ import Foreign.Storable (Storable(..))
85import GHC.Base (Addr#, nullAddr#, build)
85import GHC.Base (Addr#, nullAddr#, build)
86import GHC.Exts (IsList, IsString(..))
86import GHC.Exts (IsList, IsString(..))
87
87
88−#ifdef DEVBUILD
89−import GHC.ForeignPtr (touchForeignPtr, unsafeForeignPtrToPtr)
90−#endif
91import GHC.IO (unsafePerformIO)
88import GHC.IO (unsafePerformIO)
92import GHC.Ptr (Ptr(..))
89import GHC.Ptr (Ptr(..))
93import Streamly.Internal.Data.Array.Foreign.Mut.Type
90import Streamly.Internal.Data.Array.Foreign.Mut.Type
@@ -742,24 +739,25 @@ instance (Storable a, Ord a) => Ord (Array a) where
742--
739--
743{-# INLINE_NORMAL toStreamD_ #-}
740{-# INLINE_NORMAL toStreamD_ #-}
744toStreamD_ :: forall m a. MonadIO m => Int -> Array a -> D.Stream m a
741toStreamD_ :: forall m a. MonadIO m => Int -> Array a -> D.Stream m a
745−toStreamD_ size Array{..} =
742+toStreamD_ size Array{..} = D.Stream step arrStart
746− let p = unsafeForeignPtrToPtr aStart
747− in D.Stream step p
748
743
749 where
744 where
750
745
751 {-# INLINE_LATE step #-}
746 {-# INLINE_LATE step #-}
752 step _ p | p == aEnd = return D.Stop
747 step _ p | p == aEnd = return D.Stop
753− step _ p = do
754− x <- liftIO $ do
748+ step _ p = liftIO $ do
755− r <- peek p
749+ x <- peek p
756− touchForeignPtr aStart
750+ touch arrContents
757− return r
758 return $ D.Yield x (p `plusPtr` size)
751 return $ D.Yield x (p `plusPtr` size)
759
752
753+{-
754+
755+XXX Why isn't Storable implicit? This does not compile unless I use the Storable
756+contraint.
757+
760{-# INLINE_NORMAL _foldr #-}
758{-# INLINE_NORMAL _foldr #-}
761_foldr :: forall a b. (a -> b -> b) -> b -> Array a -> b
759_foldr :: forall a b. (a -> b -> b) -> b -> Array a -> b
762−_foldr f z arr@Array {..} =
760+_foldr f z arr =
763 let !n = sizeOf (undefined :: a)
761 let !n = sizeOf (undefined :: a)
764 in unsafePerformIO $ D.foldr f z $ toStreamD_ n arr
762 in unsafePerformIO $ D.foldr f z $ toStreamD_ n arr
765
763
@@ -767,6 +765,8 @@ _foldr f z arr@Array {..} =
767-- operations.
765-- operations.
768instance Foldable Array where
766instance Foldable Array where
769 foldr = _foldr
767 foldr = _foldr
768+
769+-}
770#endif
770#endif
771
771
772-------------------------------------------------------------------------------
772-------------------------------------------------------------------------------