on master help sign in
rename "runFold" to "fold"
16c2f01Harendra Kumar
benchmark/ArrayOps.hs+5−5
@@ -49,7 +49,7 @@ type Stream = A.Array
49
49
50{-# INLINE sourceUnfoldr #-}
50{-# INLINE sourceUnfoldr #-}
51sourceUnfoldr :: MonadIO m => Int -> m (Stream Int)
51sourceUnfoldr :: MonadIO m => Int -> m (Stream Int)
52−sourceUnfoldr n = S.runFold (A.writeN value) $ S.unfoldr step n
52+sourceUnfoldr n = S.fold (A.writeN value) $ S.unfoldr step n
53 where
53 where
54 step cnt =
54 step cnt =
55 if cnt > n + value
55 if cnt > n + value
@@ -58,18 +58,18 @@ sourceUnfoldr n = S.runFold (A.writeN value) $ S.unfoldr step n
58
58
59{-# INLINE sourceIntFromTo #-}
59{-# INLINE sourceIntFromTo #-}
60sourceIntFromTo :: MonadIO m => Int -> m (Stream Int)
60sourceIntFromTo :: MonadIO m => Int -> m (Stream Int)
61−sourceIntFromTo n = S.runFold (A.writeN value) $ S.enumerateFromTo n (n + value)
61+sourceIntFromTo n = S.fold (A.writeN value) $ S.enumerateFromTo n (n + value)
62
62
63{-# INLINE sourceIntFromToFromStream #-}
63{-# INLINE sourceIntFromToFromStream #-}
64sourceIntFromToFromStream :: MonadIO m => Int -> m (Stream Int)
64sourceIntFromToFromStream :: MonadIO m => Int -> m (Stream Int)
65−sourceIntFromToFromStream n = S.runFold A.write $ S.enumerateFromTo n (n + value)
65+sourceIntFromToFromStream n = S.fold A.write $ S.enumerateFromTo n (n + value)
66
66
67sourceIntFromToFromList :: MonadIO m => Int -> m (Stream Int)
67sourceIntFromToFromList :: MonadIO m => Int -> m (Stream Int)
68sourceIntFromToFromList n = P.return $ A.fromList $ [n..n + value]
68sourceIntFromToFromList n = P.return $ A.fromList $ [n..n + value]
69
69
70{-# INLINE sourceFromList #-}
70{-# INLINE sourceFromList #-}
71sourceFromList :: MonadIO m => Int -> m (Stream Int)
71sourceFromList :: MonadIO m => Int -> m (Stream Int)
72−sourceFromList n = S.runFold (A.writeN value) $ S.fromList [n..n+value]
72+sourceFromList n = S.fold (A.writeN value) $ S.fromList [n..n+value]
73
73
74{-# INLINE sourceIsList #-}
74{-# INLINE sourceIsList #-}
75sourceIsList :: Int -> Stream Int
75sourceIsList :: Int -> Stream Int
@@ -280,7 +280,7 @@ onArray
280 :: MonadIO m => (S.SerialT m Int -> S.SerialT m Int)
280 :: MonadIO m => (S.SerialT m Int -> S.SerialT m Int)
281 -> Stream Int
281 -> Stream Int
282 -> m (Stream Int)
282 -> m (Stream Int)
283−onArray f arr = S.runFold (A.writeN value) $ f $ A.read arr
283+onArray f arr = S.fold (A.writeN value) $ f $ A.read arr
284
284
285scanl' n = composeN n $ onArray $ S.scanl' (+) 0
285scanl' n = composeN n $ onArray $ S.scanl' (+) 0
286scanl1' n = composeN n $ onArray $ S.scanl1' (+)
286scanl1' n = composeN n $ onArray $ S.scanl1' (+)
benchmark/Linear.hs+41−41
@@ -219,42 +219,42 @@ main =
219 , benchIOSink "toListRev" Ops.toListRev
219 , benchIOSink "toListRev" Ops.toListRev
220 ]
220 ]
221 , bgroup "folds"
221 , bgroup "folds"
222− [ benchIOSink "drain" (S.runFold FL.drain)
222+ [ benchIOSink "drain" (S.fold FL.drain)
223− , benchIOSink "sink" (S.runFold $ Sink.toFold Sink.drain)
223+ , benchIOSink "sink" (S.fold $ Sink.toFold Sink.drain)
224− , benchIOSink "last" (S.runFold FL.last)
224+ , benchIOSink "last" (S.fold FL.last)
225− , benchIOSink "length" (S.runFold FL.length)
225+ , benchIOSink "length" (S.fold FL.length)
226− , benchIOSink "sum" (S.runFold FL.sum)
226+ , benchIOSink "sum" (S.fold FL.sum)
227− , benchIOSink "product" (S.runFold FL.product)
227+ , benchIOSink "product" (S.fold FL.product)
228− , benchIOSink "maximumBy" (S.runFold (FL.maximumBy compare))
228+ , benchIOSink "maximumBy" (S.fold (FL.maximumBy compare))
229− , benchIOSink "maximum" (S.runFold FL.maximum)
229+ , benchIOSink "maximum" (S.fold FL.maximum)
230− , benchIOSink "minimumBy" (S.runFold (FL.minimumBy compare))
230+ , benchIOSink "minimumBy" (S.fold (FL.minimumBy compare))
231− , benchIOSink "minimum" (S.runFold FL.minimum)
231+ , benchIOSink "minimum" (S.fold FL.minimum)
232− , benchIOSink "mean" (\s -> S.runFold FL.mean (S.map (fromIntegral :: Int -> Double) s))
232+ , benchIOSink "mean" (\s -> S.fold FL.mean (S.map (fromIntegral :: Int -> Double) s))
233− , benchIOSink "variance" (\s -> S.runFold FL.variance (S.map (fromIntegral :: Int -> Double) s))
233+ , benchIOSink "variance" (\s -> S.fold FL.variance (S.map (fromIntegral :: Int -> Double) s))
234− , benchIOSink "stdDev" (\s -> S.runFold FL.stdDev (S.map (fromIntegral :: Int -> Double) s))
234+ , benchIOSink "stdDev" (\s -> S.fold FL.stdDev (S.map (fromIntegral :: Int -> Double) s))
235−
235+
236− , benchIOSink "mconcat" (S.runFold FL.mconcat . (S.map (Last . Just)))
236+ , benchIOSink "mconcat" (S.fold FL.mconcat . (S.map (Last . Just)))
237− , benchIOSink "foldMap" (S.runFold (FL.foldMap (Last . Just)))
237+ , benchIOSink "foldMap" (S.fold (FL.foldMap (Last . Just)))
238−
238+
239− , benchIOSink "toList" (S.runFold FL.toList)
239+ , benchIOSink "toList" (S.fold FL.toList)
240− , benchIOSink "toListRevF" (S.runFold IFL.toListRevF)
240+ , benchIOSink "toListRevF" (S.fold IFL.toListRevF)
241− , benchIOSink "toStream" (S.runFold IP.toStream)
241+ , benchIOSink "toStream" (S.fold IP.toStream)
242− , benchIOSink "toStreamRev" (S.runFold IP.toStreamRev)
242+ , benchIOSink "toStreamRev" (S.fold IP.toStreamRev)
243− , benchIOSink "writeN" (S.runFold (A.writeN Ops.value))
243+ , benchIOSink "writeN" (S.fold (A.writeN Ops.value))
244−
244+
245− , benchIOSink "index" (S.runFold (FL.index Ops.maxValue))
245+ , benchIOSink "index" (S.fold (FL.index Ops.maxValue))
246− , benchIOSink "head" (S.runFold FL.head)
246+ , benchIOSink "head" (S.fold FL.head)
247− , benchIOSink "find" (S.runFold (FL.find (== Ops.maxValue)))
247+ , benchIOSink "find" (S.fold (FL.find (== Ops.maxValue)))
248− , benchIOSink "findIndex" (S.runFold (FL.findIndex (== Ops.maxValue)))
248+ , benchIOSink "findIndex" (S.fold (FL.findIndex (== Ops.maxValue)))
249− , benchIOSink "elemIndex" (S.runFold (FL.elemIndex Ops.maxValue))
249+ , benchIOSink "elemIndex" (S.fold (FL.elemIndex Ops.maxValue))
250−
250+
251− , benchIOSink "null" (S.runFold FL.null)
251+ , benchIOSink "null" (S.fold FL.null)
252− , benchIOSink "elem" (S.runFold (FL.elem Ops.maxValue))
252+ , benchIOSink "elem" (S.fold (FL.elem Ops.maxValue))
253− , benchIOSink "notElem" (S.runFold (FL.notElem Ops.maxValue))
253+ , benchIOSink "notElem" (S.fold (FL.notElem Ops.maxValue))
254− , benchIOSink "all" (S.runFold (FL.all (<= Ops.maxValue)))
254+ , benchIOSink "all" (S.fold (FL.all (<= Ops.maxValue)))
255− , benchIOSink "any" (S.runFold (FL.any (> Ops.maxValue)))
255+ , benchIOSink "any" (S.fold (FL.any (> Ops.maxValue)))
256− , benchIOSink "and" (\s -> S.runFold FL.and (S.map (<= Ops.maxValue) s))
256+ , benchIOSink "and" (\s -> S.fold FL.and (S.map (<= Ops.maxValue) s))
257− , benchIOSink "or" (\s -> S.runFold FL.or (S.map (> Ops.maxValue) s))
257+ , benchIOSink "or" (\s -> S.fold FL.or (S.map (> Ops.maxValue) s))
258 ]
258 ]
259 , bgroup "fold-multi-stream"
259 , bgroup "fold-multi-stream"
260 [ benchIOSink1 "eqBy" Ops.eqBy
260 [ benchIOSink1 "eqBy" Ops.eqBy
@@ -264,16 +264,16 @@ main =
264 , benchIOSink "stripPrefix" Ops.stripPrefix
264 , benchIOSink "stripPrefix" Ops.stripPrefix
265 ]
265 ]
266 , bgroup "folds-transforms"
266 , bgroup "folds-transforms"
267− [ benchIOSink "drain" (S.runFold FL.drain)
267+ [ benchIOSink "drain" (S.fold FL.drain)
268− , benchIOSink "lmap" (S.runFold (IFL.lmap (+1) FL.drain))
268+ , benchIOSink "lmap" (S.fold (IFL.lmap (+1) FL.drain))
269 , benchIOSink "pipe-mapM"
269 , benchIOSink "pipe-mapM"
270− (S.runFold (IFL.transform (Pipe.mapM (\x -> return $ x + 1)) FL.drain))
270+ (S.fold (IFL.transform (Pipe.mapM (\x -> return $ x + 1)) FL.drain))
271 ]
271 ]
272 , bgroup "folds-compositions" -- Applicative
272 , bgroup "folds-compositions" -- Applicative
273 [
273 [
274− benchIOSink "all,any" (S.runFold ((,) <$> FL.all (<= Ops.maxValue)
274+ benchIOSink "all,any" (S.fold ((,) <$> FL.all (<= Ops.maxValue)
275 <*> FL.any (> Ops.maxValue)))
275 <*> FL.any (> Ops.maxValue)))
276− , benchIOSink "sum,length" (S.runFold ((,) <$> FL.sum <*> FL.length))
276+ , benchIOSink "sum,length" (S.fold ((,) <$> FL.sum <*> FL.length))
277 ]
277 ]
278 , bgroup "pipes"
278 , bgroup "pipes"
279 [ benchIOSink "mapM" (Ops.transformMapM serially 1)
279 [ benchIOSink "mapM" (Ops.transformMapM serially 1)
examples/EchoServer.hs+1−1
@@ -9,4 +9,4 @@ main :: IO ()
9main = S.drain
9main = S.drain
10 $ parallely $ S.mapM (flip withSocket echo)
10 $ parallely $ S.mapM (flip withSocket echo)
11 $ serially $ connectionsOnAllAddrs 8090
11 $ serially $ connectionsOnAllAddrs 8090
12− where echo sk = S.runFold (writeArrays sk) $ readArrays sk
12+ where echo sk = S.fold (writeArrays sk) $ readArrays sk
examples/FileIOExamples.hs+2−2
@@ -30,14 +30,14 @@ grepc pat src = print . (subtract 1) =<< (S.length
30 $ File.read src)
30 $ File.read src)
31
31
32avgll :: FilePath -> IO ()
32avgll :: FilePath -> IO ()
33−avgll src = print =<< (S.runFold avg
33+avgll src = print =<< (S.fold avg
34 $ S.splitOnSuffix (== ord' '\n') FL.length
34 $ S.splitOnSuffix (== ord' '\n') FL.length
35 $ File.read src)
35 $ File.read src)
36 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
36 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
37 toDouble = fmap (fromIntegral :: Int -> Double)
37 toDouble = fmap (fromIntegral :: Int -> Double)
38
38
39llhisto :: FilePath -> IO ()
39llhisto :: FilePath -> IO ()
40−llhisto src = print =<< (S.runFold (FL.classify FL.length)
40+llhisto src = print =<< (S.fold (FL.classify FL.length)
41 $ S.map bucket
41 $ S.map bucket
42 $ S.splitOnSuffix (== ord' '\n') FL.length
42 $ S.splitOnSuffix (== ord' '\n') FL.length
43 $ File.read src)
43 $ File.read src)
examples/FileSinkServer.hs+1−1
@@ -21,7 +21,7 @@ main :: IO ()
21main = do
21main = do
22 file <- fmap head getArgs
22 file <- fmap head getArgs
23 withFile file AppendMode
23 withFile file AppendMode
24− (\src -> S.runFold (FH.write src)
24+ (\src -> S.fold (FH.write src)
25 $ encodeChar8Unchecked
25 $ encodeChar8Unchecked
26 $ S.concatMap A.read
26 $ S.concatMap A.read
27 $ S.concatMapWith parallel (flip NS.withSocketS recv)
27 $ S.concatMapWith parallel (flip NS.withSocketS recv)
examples/FromFileClient.hs+1−1
@@ -16,6 +16,6 @@ main :: IO ()
16main =
16main =
17 let sendFile file =
17 let sendFile file =
18 withFile file ReadMode $ \src ->
18 withFile file ReadMode $ \src ->
19− S.runFold (Client.writeArrays (127, 0, 0, 1) 8090)
19+ S.fold (Client.writeArrays (127, 0, 0, 1) 8090)
20 $ FH.readArrays src
20 $ FH.readArrays src
21 in getArgs >>= S.drain . parallely . S.mapM sendFile . S.fromList
21 in getArgs >>= S.drain . parallely . S.mapM sendFile . S.fromList
examples/HandleIO.hs+6−6
@@ -12,14 +12,14 @@ import System.Environment (getArgs)
12import System.IO (IOMode(..), hSeek, SeekMode(..))
12import System.IO (IOMode(..), hSeek, SeekMode(..))
13
13
14cat :: FH.Handle -> IO ()
14cat :: FH.Handle -> IO ()
15−cat src = S.runFold (FH.writeArrays FH.stdout) $ FH.readArraysOf (256*1024) src
15+cat src = S.fold (FH.writeArrays FH.stdout) $ FH.readArraysOf (256*1024) src
16-- byte stream version
16-- byte stream version
17−-- cat src = S.runFold (FH.write FH.stdout) $ FH.read src
17+-- cat src = S.fold (FH.write FH.stdout) $ FH.read src
18
18
19cp :: FH.Handle -> FH.Handle -> IO ()
19cp :: FH.Handle -> FH.Handle -> IO ()
20−cp src dst = S.runFold (FH.writeArrays dst) $ FH.readArraysOf (256*1024) src
20+cp src dst = S.fold (FH.writeArrays dst) $ FH.readArraysOf (256*1024) src
21-- byte stream version
21-- byte stream version
22−-- cp src dst = S.runFold (FH.write dst) $ FH.read src
22+-- cp src dst = S.fold (FH.write dst) $ FH.read src
23
23
24ord' :: Num a => Char -> a
24ord' :: Num a => Char -> a
25ord' = (fromIntegral . ord)
25ord' = (fromIntegral . ord)
@@ -44,14 +44,14 @@ grepc pat src = print . (subtract 1) =<< (S.length
44-}
44-}
45
45
46avgll :: FH.Handle -> IO ()
46avgll :: FH.Handle -> IO ()
47−avgll src = print =<< (S.runFold avg
47+avgll src = print =<< (S.fold avg
48 $ S.splitWithSuffix (== ord' '\n') FL.length
48 $ S.splitWithSuffix (== ord' '\n') FL.length
49 $ FH.read src)
49 $ FH.read src)
50 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
50 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
51 toDouble = fmap (fromIntegral :: Int -> Double)
51 toDouble = fmap (fromIntegral :: Int -> Double)
52
52
53llhisto :: FH.Handle -> IO ()
53llhisto :: FH.Handle -> IO ()
54−llhisto src = print =<< (S.runFold (FL.classify FL.length)
54+llhisto src = print =<< (S.fold (FL.classify FL.length)
55 $ S.map bucket
55 $ S.map bucket
56 $ S.splitWithSuffix (== ord' '\n') FL.length
56 $ S.splitWithSuffix (== ord' '\n') FL.length
57 $ FH.read src)
57 $ FH.read src)
examples/WordClassifier.hs+2−2
@@ -26,9 +26,9 @@ import System.Environment (getArgs)
26import System.IO (openFile, IOMode(..))
26import System.IO (openFile, IOMode(..))
27
27
28instance (Enum a, Storable a) => Hashable (A.Array a) where
28instance (Enum a, Storable a) => Hashable (A.Array a) where
29− hash arr = runIdentity $ Streamly.runFold Internal.rollingHash (A.read arr)
29+ hash arr = runIdentity $ Streamly.fold Internal.rollingHash (A.read arr)
30 hashWithSalt salt arr = runIdentity $
30 hashWithSalt salt arr = runIdentity $
31− Streamly.runFold (Internal.rollingHashWithSalt salt) (A.read arr)
31+ Streamly.fold (Internal.rollingHashWithSalt salt) (A.read arr)
32
32
33{-# INLINE toLower #-}
33{-# INLINE toLower #-}
34toLower :: Char -> Char
34toLower :: Char -> Char
src/Streamly/Benchmark/FileIO/Array.hs+5−5
@@ -117,7 +117,7 @@ inspect $ 'sumBytes `hasNoType` ''Step
117{-# INLINE cat #-}
117{-# INLINE cat #-}
118cat :: Handle -> Handle -> IO ()
118cat :: Handle -> Handle -> IO ()
119cat devNull inh =
119cat devNull inh =
120− S.runFold (FH.writeArrays devNull) $ FH.readArraysOf (256*1024) inh
120+ S.fold (FH.writeArrays devNull) $ FH.readArraysOf (256*1024) inh
121
121
122#ifdef INSPECTION
122#ifdef INSPECTION
123inspect $ hasNoTypeClasses 'cat
123inspect $ hasNoTypeClasses 'cat
@@ -129,7 +129,7 @@ inspect $ 'cat `hasNoType` ''Step
129copy :: Handle -> Handle -> IO ()
129copy :: Handle -> Handle -> IO ()
130copy inh outh =
130copy inh outh =
131 let s = FH.readArrays inh
131 let s = FH.readArrays inh
132− in S.runFold (FH.writeArrays outh) s
132+ in S.fold (FH.writeArrays outh) s
133
133
134#ifdef INSPECTION
134#ifdef INSPECTION
135inspect $ hasNoTypeClasses 'copy
135inspect $ hasNoTypeClasses 'copy
@@ -140,7 +140,7 @@ inspect $ 'copy `hasNoType` ''Step
140{-# INLINE linesUnlinesCopy #-}
140{-# INLINE linesUnlinesCopy #-}
141linesUnlinesCopy :: Handle -> Handle -> IO ()
141linesUnlinesCopy :: Handle -> Handle -> IO ()
142linesUnlinesCopy inh outh =
142linesUnlinesCopy inh outh =
143− S.runFold (FH.writeArraysInChunksOf (1024*1024) outh)
143+ S.fold (FH.writeArraysInChunksOf (1024*1024) outh)
144 $ Internal.insertAfterEach (return $ A.fromList [10])
144 $ Internal.insertAfterEach (return $ A.fromList [10])
145 $ AS.splitOnSuffix 10
145 $ AS.splitOnSuffix 10
146 $ FH.readArraysOf (1024*1024) inh
146 $ FH.readArraysOf (1024*1024) inh
@@ -154,7 +154,7 @@ inspect $ hasNoTypeClassesExcept 'linesUnlinesCopy [''Storable]
154{-# INLINE wordsUnwordsCopy #-}
154{-# INLINE wordsUnwordsCopy #-}
155wordsUnwordsCopy :: Handle -> Handle -> IO ()
155wordsUnwordsCopy :: Handle -> Handle -> IO ()
156wordsUnwordsCopy inh outh =
156wordsUnwordsCopy inh outh =
157− S.runFold (FH.writeArraysInChunksOf (1024*1024) outh)
157+ S.fold (FH.writeArraysInChunksOf (1024*1024) outh)
158 $ S.intersperse (A.fromList [32])
158 $ S.intersperse (A.fromList [32])
159 -- XXX use a word splitting combinator
159 -- XXX use a word splitting combinator
160 $ AS.splitOn 32
160 $ AS.splitOn 32
@@ -183,7 +183,7 @@ inspect $ hasNoTypeClasses 'decodeUtf8Lenient
183{-# INLINE copyCodecUtf8Lenient #-}
183{-# INLINE copyCodecUtf8Lenient #-}
184copyCodecUtf8Lenient :: Handle -> Handle -> IO ()
184copyCodecUtf8Lenient :: Handle -> Handle -> IO ()
185copyCodecUtf8Lenient inh outh =
185copyCodecUtf8Lenient inh outh =
186− S.runFold (FH.write outh)
186+ S.fold (FH.write outh)
187 $ SS.encodeUtf8
187 $ SS.encodeUtf8
188 $ SS.decodeUtf8ArraysLenient
188 $ SS.decodeUtf8ArraysLenient
189 $ FH.readArraysOf (1024*1024) inh
189 $ FH.readArraysOf (1024*1024) inh
src/Streamly/Benchmark/FileIO/Stream.hs+8−8
@@ -158,7 +158,7 @@ inspect $ 'sumBytes `hasNoType` ''D.ConcatMapUState
158-- | Send the file contents to /dev/null
158-- | Send the file contents to /dev/null
159{-# INLINE cat #-}
159{-# INLINE cat #-}
160cat :: Handle -> Handle -> IO ()
160cat :: Handle -> Handle -> IO ()
161−cat devNull inh = S.runFold (FH.write devNull) $ FH.read inh
161+cat devNull inh = S.fold (FH.write devNull) $ FH.read inh
162
162
163#ifdef INSPECTION
163#ifdef INSPECTION
164inspect $ hasNoTypeClasses 'cat
164inspect $ hasNoTypeClasses 'cat
@@ -182,7 +182,7 @@ inspect $ 'catStreamWrite `hasNoType` ''D.ConcatMapUState
182-- | Copy file
182-- | Copy file
183{-# INLINE copy #-}
183{-# INLINE copy #-}
184copy :: Handle -> Handle -> IO ()
184copy :: Handle -> Handle -> IO ()
185−copy inh outh = S.runFold (FH.write outh) (FH.read inh)
185+copy inh outh = S.fold (FH.write outh) (FH.read inh)
186
186
187#ifdef INSPECTION
187#ifdef INSPECTION
188inspect $ hasNoTypeClasses 'copy
188inspect $ hasNoTypeClasses 'copy
@@ -206,7 +206,7 @@ decodeChar8 inh =
206{-# INLINE copyCodecChar8 #-}
206{-# INLINE copyCodecChar8 #-}
207copyCodecChar8 :: Handle -> Handle -> IO ()
207copyCodecChar8 :: Handle -> Handle -> IO ()
208copyCodecChar8 inh outh =
208copyCodecChar8 inh outh =
209− S.runFold (FH.write outh)
209+ S.fold (FH.write outh)
210 $ SS.encodeChar8
210 $ SS.encodeChar8
211 $ SS.decodeChar8
211 $ SS.decodeChar8
212 $ FH.read inh
212 $ FH.read inh
@@ -236,7 +236,7 @@ inspect $ hasNoTypeClasses 'decodeUtf8Lenient
236{-# INLINE copyCodecUtf8 #-}
236{-# INLINE copyCodecUtf8 #-}
237copyCodecUtf8 :: Handle -> Handle -> IO ()
237copyCodecUtf8 :: Handle -> Handle -> IO ()
238copyCodecUtf8 inh outh =
238copyCodecUtf8 inh outh =
239− S.runFold (FH.write outh)
239+ S.fold (FH.write outh)
240 $ SS.encodeUtf8
240 $ SS.encodeUtf8
241 $ SS.decodeUtf8
241 $ SS.decodeUtf8
242 $ FH.read inh
242 $ FH.read inh
@@ -252,7 +252,7 @@ inspect $ hasNoTypeClasses 'copyCodecUtf8
252{-# INLINE copyCodecUtf8Lenient #-}
252{-# INLINE copyCodecUtf8Lenient #-}
253copyCodecUtf8Lenient :: Handle -> Handle -> IO ()
253copyCodecUtf8Lenient :: Handle -> Handle -> IO ()
254copyCodecUtf8Lenient inh outh =
254copyCodecUtf8Lenient inh outh =
255− S.runFold (FH.write outh)
255+ S.fold (FH.write outh)
256 $ SS.encodeUtf8
256 $ SS.encodeUtf8
257 $ SS.decodeUtf8Lenient
257 $ SS.decodeUtf8Lenient
258 $ FH.read inh
258 $ FH.read inh
@@ -303,7 +303,7 @@ inspect $ 'chunksOfD `hasNoType` ''D.ConcatMapUState
303{-# INLINE linesUnlinesCopy #-}
303{-# INLINE linesUnlinesCopy #-}
304linesUnlinesCopy :: Handle -> Handle -> IO ()
304linesUnlinesCopy :: Handle -> Handle -> IO ()
305linesUnlinesCopy inh outh =
305linesUnlinesCopy inh outh =
306− S.runFold (FH.write outh)
306+ S.fold (FH.write outh)
307 $ SS.encodeChar8
307 $ SS.encodeChar8
308 $ SS.unlines
308 $ SS.unlines
309 $ SS.lines
309 $ SS.lines
@@ -343,7 +343,7 @@ isSp = isSpace . chr . fromIntegral
343{-# INLINE wordsUnwordsCopyWord8 #-}
343{-# INLINE wordsUnwordsCopyWord8 #-}
344wordsUnwordsCopyWord8 :: Handle -> Handle -> IO ()
344wordsUnwordsCopyWord8 :: Handle -> Handle -> IO ()
345wordsUnwordsCopyWord8 inh outh =
345wordsUnwordsCopyWord8 inh outh =
346− S.runFold (FH.write outh)
346+ S.fold (FH.write outh)
347 $ IP.concatMapU IUF.fromList
347 $ IP.concatMapU IUF.fromList
348 $ S.intersperse [32]
348 $ S.intersperse [32]
349 $ S.wordsBy isSp FL.toList
349 $ S.wordsBy isSp FL.toList
@@ -359,7 +359,7 @@ inspect $ hasNoTypeClasses 'wordsUnwordsCopyWord8
359{-# INLINE wordsUnwordsCopy #-}
359{-# INLINE wordsUnwordsCopy #-}
360wordsUnwordsCopy :: Handle -> Handle -> IO ()
360wordsUnwordsCopy :: Handle -> Handle -> IO ()
361wordsUnwordsCopy inh outh =
361wordsUnwordsCopy inh outh =
362− S.runFold (FH.write outh)
362+ S.fold (FH.write outh)
363 $ SS.encodeChar8
363 $ SS.encodeChar8
364 $ IP.concatMapU IUF.fromList
364 $ IP.concatMapU IUF.fromList
365 $ S.intersperse " "
365 $ S.intersperse " "
src/Streamly/Internal/Prelude.hs+11−11
@@ -77,7 +77,7 @@ module Streamly.Internal.Prelude
77 , foldlM'
77 , foldlM'
78
78
79 -- ** Composable Left Folds
79 -- ** Composable Left Folds
80− , runFold
80+ , fold
81
81
82 -- ** Full Folds
82 -- ** Full Folds
83
83
@@ -968,13 +968,13 @@ foldlM' step begin m = S.foldlM' step begin $ toStreamS m
968
968
969-- | Fold a stream using the supplied left fold.
969-- | Fold a stream using the supplied left fold.
970--
970--
971−-- >>> S.runFold FL.sum (S.enumerateFromTo 1 100)
971+-- >>> S.fold FL.sum (S.enumerateFromTo 1 100)
972-- 5050
972-- 5050
973--
973--
974-- @since 0.7.0
974-- @since 0.7.0
975−{-# INLINE runFold #-}
975+{-# INLINE fold #-}
976−runFold :: Monad m => Fold m a b -> SerialT m a -> m b
976+fold :: Monad m => Fold m a b -> SerialT m a -> m b
977−runFold = P.runFold
977+fold = P.runFold
978
978
979------------------------------------------------------------------------------
979------------------------------------------------------------------------------
980-- Running a sink
980-- Running a sink
@@ -984,7 +984,7 @@ runFold = P.runFold
984-- | Drain a stream to a 'Sink'.
984-- | Drain a stream to a 'Sink'.
985{-# INLINE runSink #-}
985{-# INLINE runSink #-}
986runSink :: Monad m => Sink m a -> SerialT m a -> m ()
986runSink :: Monad m => Sink m a -> SerialT m a -> m ()
987−runSink = runFold . toFold
987+runSink = fold . toFold
988-}
988-}
989
989
990------------------------------------------------------------------------------
990------------------------------------------------------------------------------
@@ -2275,7 +2275,7 @@ intercalateSuffix suffix seed unf str =
2275-- elements of its input are consumed by fold @f1@ and the rest of the stream
2275-- elements of its input are consumed by fold @f1@ and the rest of the stream
2276-- is consumed by fold @f2@.
2276-- is consumed by fold @f2@.
2277--
2277--
2278−-- > let splitAt_ n xs = S.runFold (FL.splitAt n FL.toList FL.toList) $ S.fromList xs
2278+-- > let splitAt_ n xs = S.fold (FL.splitAt n FL.toList FL.toList) $ S.fromList xs
2279--
2279--
2280-- >>> splitAt_ 6 "Hello World!"
2280-- >>> splitAt_ 6 "Hello World!"
2281-- > ("Hello ","World!")
2281-- > ("Hello ","World!")
@@ -2452,7 +2452,7 @@ spanBy cmp (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
2452-- input as long as the predicate @p@ is 'True'. @f2@ consumes the rest of the
2452-- input as long as the predicate @p@ is 'True'. @f2@ consumes the rest of the
2453-- input.
2453-- input.
2454--
2454--
2455−-- > let span_ p xs = S.runFold (S.span p FL.toList FL.toList) $ S.fromList xs
2455+-- > let span_ p xs = S.fold (S.span p FL.toList FL.toList) $ S.fromList xs
2456--
2456--
2457-- >>> span_ (< 1) [1,2,3]
2457-- >>> span_ (< 1) [1,2,3]
2458-- > ([],[1,2,3])
2458-- > ([],[1,2,3])
@@ -2497,7 +2497,7 @@ span p (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
2497--
2497--
2498-- This is the binary version of 'splitBy'.
2498-- This is the binary version of 'splitBy'.
2499--
2499--
2500−-- > let break_ p xs = S.runFold (S.break p FL.toList FL.toList) $ S.fromList xs
2500+-- > let break_ p xs = S.fold (S.break p FL.toList FL.toList) $ S.fromList xs
2501--
2501--
2502-- >>> break_ (< 1) [3,2,1]
2502-- >>> break_ (< 1) [3,2,1]
2503-- > ([3,2,1],[])
2503-- > ([3,2,1],[])
@@ -2611,7 +2611,7 @@ groups = groupsBy (==)
2611-- stream before the sequence and the second part consisting of the sequence
2611-- stream before the sequence and the second part consisting of the sequence
2612-- and the rest of the stream.
2612-- and the rest of the stream.
2613--
2613--
2614−-- > let breakOn_ pat xs = S.runFold (S.breakOn pat FL.toList FL.toList) $ S.fromList xs
2614+-- > let breakOn_ pat xs = S.fold (S.breakOn pat FL.toList FL.toList) $ S.fromList xs
2615--
2615--
2616-- >>> breakOn_ "dear" "Hello dear world!"
2616-- >>> breakOn_ "dear" "Hello dear world!"
2617-- > ("Hello ","dear world!")
2617-- > ("Hello ","dear world!")
@@ -2988,7 +2988,7 @@ wordsOn subseq f m = undefined -- D.fromStreamD $ D.wordsOn f subseq (D.toStream
2988splitBySeq
2988splitBySeq
2989 :: (IsStream t, MonadAsync m, Storable a, Enum a, Eq a)
2989 :: (IsStream t, MonadAsync m, Storable a, Enum a, Eq a)
2990 => Array a -> Fold m a b -> t m a -> t m b
2990 => Array a -> Fold m a b -> t m a -> t m b
2991−splitBySeq patt f m = intersperseM (runFold f (A.read patt)) $ splitOnSeq patt f m
2991+splitBySeq patt f m = intersperseM (fold f (A.read patt)) $ splitOnSeq patt f m
2992
2992
2993-- | Like 'splitSuffixOn' but keeps the suffix intact in the splits.
2993-- | Like 'splitSuffixOn' but keeps the suffix intact in the splits.
2994--
2994--
src/Streamly/Prelude.hs+4−4
@@ -186,7 +186,7 @@ module Streamly.Prelude
186 -- ** Composable Left Folds
186 -- ** Composable Left Folds
187 -- $runningfolds
187 -- $runningfolds
188
188
189− , runFold
189+ , fold
190
190
191 -- ** Full Folds
191 -- ** Full Folds
192 -- | Folds that are guaranteed to evaluate the whole stream.
192 -- | Folds that are guaranteed to evaluate the whole stream.
@@ -885,11 +885,11 @@ import Streamly.Internal.Prelude
885-- $runningfolds
885-- $runningfolds
886--
886--
887-- "Streamly.Data.Fold" module defines composable left folds which can be combined
887-- "Streamly.Data.Fold" module defines composable left folds which can be combined
888−-- together in many interesting ways. Those folds can be run using 'runFold'.
888+-- together in many interesting ways. Those folds can be run using 'fold'.
889-- The following two ways of folding are equivalent in functionality and
889-- The following two ways of folding are equivalent in functionality and
890-- performance,
890-- performance,
891--
891--
892−-- >>> S.runFold FL.sum (S.enumerateFromTo 1 100)
892+-- >>> S.fold FL.sum (S.enumerateFromTo 1 100)
893-- 5050
893-- 5050
894-- >>> S.sum (S.enumerateFromTo 1 100)
894-- >>> S.sum (S.enumerateFromTo 1 100)
895-- 5050
895-- 5050
@@ -905,7 +905,7 @@ import Streamly.Internal.Prelude
905--
905--
906-- >>> S.head (1 `S.cons` undefined)
906-- >>> S.head (1 `S.cons` undefined)
907-- Just 1
907-- Just 1
908−-- >>> S.runFold FL.head (1 `S.cons` undefined)
908+-- >>> S.fold FL.head (1 `S.cons` undefined)
909-- *** Exception: Prelude.undefined
909-- *** Exception: Prelude.undefined
910--
910--
911-- However, we can wrap the fold in a scan to convert it into a lazy stream of
911-- However, we can wrap the fold in a scan to convert it into a lazy stream of
test/Arrays.hs+4−4
@@ -43,7 +43,7 @@ testLength =
43 forAll (choose (0, maxArrLen)) $ \len ->
43 forAll (choose (0, maxArrLen)) $ \len ->
44 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
44 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
45 monadicIO $ do
45 monadicIO $ do
46− arr <- S.runFold (A.writeN len)
46+ arr <- S.fold (A.writeN len)
47 $ S.fromList list
47 $ S.fromList list
48 assert (A.length arr == len)
48 assert (A.length arr == len)
49
49
@@ -52,7 +52,7 @@ testFromToStreamN =
52 forAll (choose (0, maxArrLen)) $ \len ->
52 forAll (choose (0, maxArrLen)) $ \len ->
53 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
53 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
54 monadicIO $ do
54 monadicIO $ do
55− arr <- S.runFold (A.writeN len)
55+ arr <- S.fold (A.writeN len)
56 $ S.fromList list
56 $ S.fromList list
57 xs <- S.toList
57 xs <- S.toList
58 $ A.read arr
58 $ A.read arr
@@ -63,7 +63,7 @@ testToStreamRev =
63 forAll (choose (0, maxArrLen)) $ \len ->
63 forAll (choose (0, maxArrLen)) $ \len ->
64 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
64 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
65 monadicIO $ do
65 monadicIO $ do
66− arr <- S.runFold (A.writeN len)
66+ arr <- S.fold (A.writeN len)
67 $ S.fromList list
67 $ S.fromList list
68 xs <- S.toList
68 xs <- S.toList
69 $ A.readRev arr
69 $ A.readRev arr
@@ -96,7 +96,7 @@ testFromToStream =
96 forAll (choose (0, maxArrLen)) $ \len ->
96 forAll (choose (0, maxArrLen)) $ \len ->
97 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
97 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
98 monadicIO $ do
98 monadicIO $ do
99− arr <- S.runFold A.write $ S.fromList list
99+ arr <- S.fold A.write $ S.fromList list
100 xs <- S.toList
100 xs <- S.toList
101 $ A.read arr
101 $ A.read arr
102 assert (xs == list)
102 assert (xs == list)
test/String.hs+1−1
@@ -57,7 +57,7 @@ propDecodeEncodeIdArrays =
57 monadicIO $ do
57 monadicIO $ do
58 let wrds = SS.encodeUtf8 $ S.fromList list
58 let wrds = SS.encodeUtf8 $ S.fromList list
59 chrs <- S.toList $ SS.decodeUtf8ArraysLenient
59 chrs <- S.toList $ SS.decodeUtf8ArraysLenient
60− (S.runFold A.write wrds)
60+ (S.fold A.write wrds)
61 assert (chrs == list)
61 assert (chrs == list)
62
62
63testLines :: Property
63testLines :: Property