on master help sign in
rename "runFold" to "fold"

* we are using "unfold" for unfolding, runUnfold is longer and sounds a bit weird. So similar to "unfold" we should use "fold" for folding. * Another reason is that "runFold" sound ends in "unfold" so can sound confusing.

commit16c2f015c2c24e66b8bc74697023117bc3b7101c authorHarendra Kumar <harendra.kumar@gmail.com> dateSun 29 Sep 2019, 14:52 (7 years ago) parenta1b9762
14 files changed+92−92
benchmark/ArrayOps.hs+5−5 benchmark/Linear.hs+41−41 examples/EchoServer.hs+1−1 examples/FileIOExamples.hs+2−2 examples/FileSinkServer.hs+1−1 examples/FromFileClient.hs+1−1 examples/HandleIO.hs+6−6 examples/WordClassifier.hs+2−2 src/Streamly/Benchmark/FileIO/Array.hs+5−5 src/Streamly/Benchmark/FileIO/Stream.hs+8−8 src/Streamly/Internal/Prelude.hs+11−11 src/Streamly/Prelude.hs+4−4 test/Arrays.hs+4−4 test/String.hs+1−1
benchmark/ArrayOps.hs+5−5
@@ -49,7 +49,7 @@ type Stream = A.Array
4949
5050{-# INLINE sourceUnfoldr #-}
5151sourceUnfoldr :: 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
5353 where
5454 step cnt =
5555 if cnt > n + value
@@ -58,18 +58,18 @@ sourceUnfoldr n = S.runFold (A.writeN value) $ S.unfoldr step n
5858
5959{-# INLINE sourceIntFromTo #-}
6060sourceIntFromTo :: 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)
6262
6363{-# INLINE sourceIntFromToFromStream #-}
6464sourceIntFromToFromStream :: 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)
6666
6767sourceIntFromToFromList :: MonadIO m => Int -> m (Stream Int)
6868sourceIntFromToFromList n = P.return $ A.fromList $ [n..n + value]
6969
7070{-# INLINE sourceFromList #-}
7171sourceFromList :: 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]
7373
7474{-# INLINE sourceIsList #-}
7575sourceIsList :: Int -> Stream Int
@@ -280,7 +280,7 @@ onArray
280280 :: MonadIO m => (S.SerialT m Int -> S.SerialT m Int)
281281 -> Stream Int
282282 -> 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
284284
285285scanl' n = composeN n $ onArray $ S.scanl' (+) 0
286286scanl1' n = composeN n $ onArray $ S.scanl1' (+)
benchmark/Linear.hs+41−41
@@ -219,42 +219,42 @@ main =
219219 , benchIOSink "toListRev" Ops.toListRev
220220 ]
221221 , bgroup "folds"
222− [ benchIOSink "drain" (S.runFold FL.drain)
223− , benchIOSink "sink" (S.runFold $ Sink.toFold Sink.drain)
224− , benchIOSink "last" (S.runFold FL.last)
225− , benchIOSink "length" (S.runFold FL.length)
226− , benchIOSink "sum" (S.runFold FL.sum)
227− , benchIOSink "product" (S.runFold FL.product)
228− , benchIOSink "maximumBy" (S.runFold (FL.maximumBy compare))
229− , benchIOSink "maximum" (S.runFold FL.maximum)
230− , benchIOSink "minimumBy" (S.runFold (FL.minimumBy compare))
231− , benchIOSink "minimum" (S.runFold FL.minimum)
232− , benchIOSink "mean" (\s -> S.runFold FL.mean (S.map (fromIntegral :: Int -> Double) s))
233− , benchIOSink "variance" (\s -> S.runFold FL.variance (S.map (fromIntegral :: Int -> Double) s))
234− , benchIOSink "stdDev" (\s -> S.runFold FL.stdDev (S.map (fromIntegral :: Int -> Double) s))
235−
236− , benchIOSink "mconcat" (S.runFold FL.mconcat . (S.map (Last . Just)))
237− , benchIOSink "foldMap" (S.runFold (FL.foldMap (Last . Just)))
238−
239− , benchIOSink "toList" (S.runFold FL.toList)
240− , benchIOSink "toListRevF" (S.runFold IFL.toListRevF)
241− , benchIOSink "toStream" (S.runFold IP.toStream)
242− , benchIOSink "toStreamRev" (S.runFold IP.toStreamRev)
243− , benchIOSink "writeN" (S.runFold (A.writeN Ops.value))
244−
245− , benchIOSink "index" (S.runFold (FL.index Ops.maxValue))
246− , benchIOSink "head" (S.runFold FL.head)
247− , benchIOSink "find" (S.runFold (FL.find (== Ops.maxValue)))
248− , benchIOSink "findIndex" (S.runFold (FL.findIndex (== Ops.maxValue)))
249− , benchIOSink "elemIndex" (S.runFold (FL.elemIndex Ops.maxValue))
250−
251− , benchIOSink "null" (S.runFold FL.null)
252− , benchIOSink "elem" (S.runFold (FL.elem Ops.maxValue))
253− , benchIOSink "notElem" (S.runFold (FL.notElem Ops.maxValue))
254− , benchIOSink "all" (S.runFold (FL.all (<= Ops.maxValue)))
255− , benchIOSink "any" (S.runFold (FL.any (> Ops.maxValue)))
256− , benchIOSink "and" (\s -> S.runFold FL.and (S.map (<= Ops.maxValue) s))
257− , benchIOSink "or" (\s -> S.runFold FL.or (S.map (> Ops.maxValue) s))
222+ [ benchIOSink "drain" (S.fold FL.drain)
223+ , benchIOSink "sink" (S.fold $ Sink.toFold Sink.drain)
224+ , benchIOSink "last" (S.fold FL.last)
225+ , benchIOSink "length" (S.fold FL.length)
226+ , benchIOSink "sum" (S.fold FL.sum)
227+ , benchIOSink "product" (S.fold FL.product)
228+ , benchIOSink "maximumBy" (S.fold (FL.maximumBy compare))
229+ , benchIOSink "maximum" (S.fold FL.maximum)
230+ , benchIOSink "minimumBy" (S.fold (FL.minimumBy compare))
231+ , benchIOSink "minimum" (S.fold FL.minimum)
232+ , benchIOSink "mean" (\s -> S.fold FL.mean (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.fold FL.stdDev (S.map (fromIntegral :: Int -> Double) s))
235+
236+ , benchIOSink "mconcat" (S.fold FL.mconcat . (S.map (Last . Just)))
237+ , benchIOSink "foldMap" (S.fold (FL.foldMap (Last . Just)))
238+
239+ , benchIOSink "toList" (S.fold FL.toList)
240+ , benchIOSink "toListRevF" (S.fold IFL.toListRevF)
241+ , benchIOSink "toStream" (S.fold IP.toStream)
242+ , benchIOSink "toStreamRev" (S.fold IP.toStreamRev)
243+ , benchIOSink "writeN" (S.fold (A.writeN Ops.value))
244+
245+ , benchIOSink "index" (S.fold (FL.index Ops.maxValue))
246+ , benchIOSink "head" (S.fold FL.head)
247+ , benchIOSink "find" (S.fold (FL.find (== Ops.maxValue)))
248+ , benchIOSink "findIndex" (S.fold (FL.findIndex (== Ops.maxValue)))
249+ , benchIOSink "elemIndex" (S.fold (FL.elemIndex Ops.maxValue))
250+
251+ , benchIOSink "null" (S.fold FL.null)
252+ , benchIOSink "elem" (S.fold (FL.elem Ops.maxValue))
253+ , benchIOSink "notElem" (S.fold (FL.notElem Ops.maxValue))
254+ , benchIOSink "all" (S.fold (FL.all (<= Ops.maxValue)))
255+ , benchIOSink "any" (S.fold (FL.any (> Ops.maxValue)))
256+ , benchIOSink "and" (\s -> S.fold FL.and (S.map (<= Ops.maxValue) s))
257+ , benchIOSink "or" (\s -> S.fold FL.or (S.map (> Ops.maxValue) s))
258258 ]
259259 , bgroup "fold-multi-stream"
260260 [ benchIOSink1 "eqBy" Ops.eqBy
@@ -264,16 +264,16 @@ main =
264264 , benchIOSink "stripPrefix" Ops.stripPrefix
265265 ]
266266 , bgroup "folds-transforms"
267− [ benchIOSink "drain" (S.runFold FL.drain)
268− , benchIOSink "lmap" (S.runFold (IFL.lmap (+1) FL.drain))
267+ [ benchIOSink "drain" (S.fold FL.drain)
268+ , benchIOSink "lmap" (S.fold (IFL.lmap (+1) FL.drain))
269269 , 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))
271271 ]
272272 , bgroup "folds-compositions" -- Applicative
273273 [
274− benchIOSink "all,any" (S.runFold ((,) <$> FL.all (<= Ops.maxValue)
274+ benchIOSink "all,any" (S.fold ((,) <$> FL.all (<= Ops.maxValue)
275275 <*> FL.any (> Ops.maxValue)))
276− , benchIOSink "sum,length" (S.runFold ((,) <$> FL.sum <*> FL.length))
276+ , benchIOSink "sum,length" (S.fold ((,) <$> FL.sum <*> FL.length))
277277 ]
278278 , bgroup "pipes"
279279 [ benchIOSink "mapM" (Ops.transformMapM serially 1)
examples/EchoServer.hs+1−1
@@ -9,4 +9,4 @@ main :: IO ()
99main = S.drain
1010 $ parallely $ S.mapM (flip withSocket echo)
1111 $ 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
3030 $ File.read src)
3131
3232avgll :: FilePath -> IO ()
33−avgll src = print =<< (S.runFold avg
33+avgll src = print =<< (S.fold avg
3434 $ S.splitOnSuffix (== ord' '\n') FL.length
3535 $ File.read src)
3636 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
3737 toDouble = fmap (fromIntegral :: Int -> Double)
3838
3939llhisto :: FilePath -> IO ()
40−llhisto src = print =<< (S.runFold (FL.classify FL.length)
40+llhisto src = print =<< (S.fold (FL.classify FL.length)
4141 $ S.map bucket
4242 $ S.splitOnSuffix (== ord' '\n') FL.length
4343 $ File.read src)
examples/FileSinkServer.hs+1−1
@@ -21,7 +21,7 @@ main :: IO ()
2121main = do
2222 file <- fmap head getArgs
2323 withFile file AppendMode
24− (\src -> S.runFold (FH.write src)
24+ (\src -> S.fold (FH.write src)
2525 $ encodeChar8Unchecked
2626 $ S.concatMap A.read
2727 $ S.concatMapWith parallel (flip NS.withSocketS recv)
examples/FromFileClient.hs+1−1
@@ -16,6 +16,6 @@ main :: IO ()
1616main =
1717 let sendFile file =
1818 withFile file ReadMode $ \src ->
19− S.runFold (Client.writeArrays (127, 0, 0, 1) 8090)
19+ S.fold (Client.writeArrays (127, 0, 0, 1) 8090)
2020 $ FH.readArrays src
2121 in getArgs >>= S.drain . parallely . S.mapM sendFile . S.fromList
examples/HandleIO.hs+6−6
@@ -12,14 +12,14 @@ import System.Environment (getArgs)
1212import System.IO (IOMode(..), hSeek, SeekMode(..))
1313
1414cat :: 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
1616-- 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
1818
1919cp :: 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
2121-- 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
2323
2424ord' :: Num a => Char -> a
2525ord' = (fromIntegral . ord)
@@ -44,14 +44,14 @@ grepc pat src = print . (subtract 1) =<< (S.length
4444-}
4545
4646avgll :: FH.Handle -> IO ()
47−avgll src = print =<< (S.runFold avg
47+avgll src = print =<< (S.fold avg
4848 $ S.splitWithSuffix (== ord' '\n') FL.length
4949 $ FH.read src)
5050 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
5151 toDouble = fmap (fromIntegral :: Int -> Double)
5252
5353llhisto :: FH.Handle -> IO ()
54−llhisto src = print =<< (S.runFold (FL.classify FL.length)
54+llhisto src = print =<< (S.fold (FL.classify FL.length)
5555 $ S.map bucket
5656 $ S.splitWithSuffix (== ord' '\n') FL.length
5757 $ FH.read src)
examples/WordClassifier.hs+2−2
@@ -26,9 +26,9 @@ import System.Environment (getArgs)
2626import System.IO (openFile, IOMode(..))
2727
2828instance (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)
3030 hashWithSalt salt arr = runIdentity $
31− Streamly.runFold (Internal.rollingHashWithSalt salt) (A.read arr)
31+ Streamly.fold (Internal.rollingHashWithSalt salt) (A.read arr)
3232
3333{-# INLINE toLower #-}
3434toLower :: Char -> Char
src/Streamly/Benchmark/FileIO/Array.hs+5−5
@@ -117,7 +117,7 @@ inspect $ 'sumBytes `hasNoType` ''Step
117117{-# INLINE cat #-}
118118cat :: Handle -> Handle -> IO ()
119119cat devNull inh =
120− S.runFold (FH.writeArrays devNull) $ FH.readArraysOf (256*1024) inh
120+ S.fold (FH.writeArrays devNull) $ FH.readArraysOf (256*1024) inh
121121
122122#ifdef INSPECTION
123123inspect $ hasNoTypeClasses 'cat
@@ -129,7 +129,7 @@ inspect $ 'cat `hasNoType` ''Step
129129copy :: Handle -> Handle -> IO ()
130130copy inh outh =
131131 let s = FH.readArrays inh
132− in S.runFold (FH.writeArrays outh) s
132+ in S.fold (FH.writeArrays outh) s
133133
134134#ifdef INSPECTION
135135inspect $ hasNoTypeClasses 'copy
@@ -140,7 +140,7 @@ inspect $ 'copy `hasNoType` ''Step
140140{-# INLINE linesUnlinesCopy #-}
141141linesUnlinesCopy :: Handle -> Handle -> IO ()
142142linesUnlinesCopy inh outh =
143− S.runFold (FH.writeArraysInChunksOf (1024*1024) outh)
143+ S.fold (FH.writeArraysInChunksOf (1024*1024) outh)
144144 $ Internal.insertAfterEach (return $ A.fromList [10])
145145 $ AS.splitOnSuffix 10
146146 $ FH.readArraysOf (1024*1024) inh
@@ -154,7 +154,7 @@ inspect $ hasNoTypeClassesExcept 'linesUnlinesCopy [''Storable]
154154{-# INLINE wordsUnwordsCopy #-}
155155wordsUnwordsCopy :: Handle -> Handle -> IO ()
156156wordsUnwordsCopy inh outh =
157− S.runFold (FH.writeArraysInChunksOf (1024*1024) outh)
157+ S.fold (FH.writeArraysInChunksOf (1024*1024) outh)
158158 $ S.intersperse (A.fromList [32])
159159 -- XXX use a word splitting combinator
160160 $ AS.splitOn 32
@@ -183,7 +183,7 @@ inspect $ hasNoTypeClasses 'decodeUtf8Lenient
183183{-# INLINE copyCodecUtf8Lenient #-}
184184copyCodecUtf8Lenient :: Handle -> Handle -> IO ()
185185copyCodecUtf8Lenient inh outh =
186− S.runFold (FH.write outh)
186+ S.fold (FH.write outh)
187187 $ SS.encodeUtf8
188188 $ SS.decodeUtf8ArraysLenient
189189 $ FH.readArraysOf (1024*1024) inh
src/Streamly/Benchmark/FileIO/Stream.hs+8−8
@@ -158,7 +158,7 @@ inspect $ 'sumBytes `hasNoType` ''D.ConcatMapUState
158158-- | Send the file contents to /dev/null
159159{-# INLINE cat #-}
160160cat :: 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
162162
163163#ifdef INSPECTION
164164inspect $ hasNoTypeClasses 'cat
@@ -182,7 +182,7 @@ inspect $ 'catStreamWrite `hasNoType` ''D.ConcatMapUState
182182-- | Copy file
183183{-# INLINE copy #-}
184184copy :: 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)
186186
187187#ifdef INSPECTION
188188inspect $ hasNoTypeClasses 'copy
@@ -206,7 +206,7 @@ decodeChar8 inh =
206206{-# INLINE copyCodecChar8 #-}
207207copyCodecChar8 :: Handle -> Handle -> IO ()
208208copyCodecChar8 inh outh =
209− S.runFold (FH.write outh)
209+ S.fold (FH.write outh)
210210 $ SS.encodeChar8
211211 $ SS.decodeChar8
212212 $ FH.read inh
@@ -236,7 +236,7 @@ inspect $ hasNoTypeClasses 'decodeUtf8Lenient
236236{-# INLINE copyCodecUtf8 #-}
237237copyCodecUtf8 :: Handle -> Handle -> IO ()
238238copyCodecUtf8 inh outh =
239− S.runFold (FH.write outh)
239+ S.fold (FH.write outh)
240240 $ SS.encodeUtf8
241241 $ SS.decodeUtf8
242242 $ FH.read inh
@@ -252,7 +252,7 @@ inspect $ hasNoTypeClasses 'copyCodecUtf8
252252{-# INLINE copyCodecUtf8Lenient #-}
253253copyCodecUtf8Lenient :: Handle -> Handle -> IO ()
254254copyCodecUtf8Lenient inh outh =
255− S.runFold (FH.write outh)
255+ S.fold (FH.write outh)
256256 $ SS.encodeUtf8
257257 $ SS.decodeUtf8Lenient
258258 $ FH.read inh
@@ -303,7 +303,7 @@ inspect $ 'chunksOfD `hasNoType` ''D.ConcatMapUState
303303{-# INLINE linesUnlinesCopy #-}
304304linesUnlinesCopy :: Handle -> Handle -> IO ()
305305linesUnlinesCopy inh outh =
306− S.runFold (FH.write outh)
306+ S.fold (FH.write outh)
307307 $ SS.encodeChar8
308308 $ SS.unlines
309309 $ SS.lines
@@ -343,7 +343,7 @@ isSp = isSpace . chr . fromIntegral
343343{-# INLINE wordsUnwordsCopyWord8 #-}
344344wordsUnwordsCopyWord8 :: Handle -> Handle -> IO ()
345345wordsUnwordsCopyWord8 inh outh =
346− S.runFold (FH.write outh)
346+ S.fold (FH.write outh)
347347 $ IP.concatMapU IUF.fromList
348348 $ S.intersperse [32]
349349 $ S.wordsBy isSp FL.toList
@@ -359,7 +359,7 @@ inspect $ hasNoTypeClasses 'wordsUnwordsCopyWord8
359359{-# INLINE wordsUnwordsCopy #-}
360360wordsUnwordsCopy :: Handle -> Handle -> IO ()
361361wordsUnwordsCopy inh outh =
362− S.runFold (FH.write outh)
362+ S.fold (FH.write outh)
363363 $ SS.encodeChar8
364364 $ IP.concatMapU IUF.fromList
365365 $ S.intersperse " "
src/Streamly/Internal/Prelude.hs+11−11
@@ -77,7 +77,7 @@ module Streamly.Internal.Prelude
7777 , foldlM'
7878
7979 -- ** Composable Left Folds
80− , runFold
80+ , fold
8181
8282 -- ** Full Folds
8383
@@ -968,13 +968,13 @@ foldlM' step begin m = S.foldlM' step begin $ toStreamS m
968968
969969-- | Fold a stream using the supplied left fold.
970970--
971−-- >>> S.runFold FL.sum (S.enumerateFromTo 1 100)
971+-- >>> S.fold FL.sum (S.enumerateFromTo 1 100)
972972-- 5050
973973--
974974-- @since 0.7.0
975−{-# INLINE runFold #-}
976−runFold :: Monad m => Fold m a b -> SerialT m a -> m b
977−runFold = P.runFold
975+{-# INLINE fold #-}
976+fold :: Monad m => Fold m a b -> SerialT m a -> m b
977+fold = P.runFold
978978
979979------------------------------------------------------------------------------
980980-- Running a sink
@@ -984,7 +984,7 @@ runFold = P.runFold
984984-- | Drain a stream to a 'Sink'.
985985{-# INLINE runSink #-}
986986runSink :: Monad m => Sink m a -> SerialT m a -> m ()
987−runSink = runFold . toFold
987+runSink = fold . toFold
988988-}
989989
990990------------------------------------------------------------------------------
@@ -2275,7 +2275,7 @@ intercalateSuffix suffix seed unf str =
22752275-- elements of its input are consumed by fold @f1@ and the rest of the stream
22762276-- is consumed by fold @f2@.
22772277--
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
22792279--
22802280-- >>> splitAt_ 6 "Hello World!"
22812281-- > ("Hello ","World!")
@@ -2452,7 +2452,7 @@ spanBy cmp (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
24522452-- input as long as the predicate @p@ is 'True'. @f2@ consumes the rest of the
24532453-- input.
24542454--
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
24562456--
24572457-- >>> span_ (< 1) [1,2,3]
24582458-- > ([],[1,2,3])
@@ -2497,7 +2497,7 @@ span p (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
24972497--
24982498-- This is the binary version of 'splitBy'.
24992499--
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
25012501--
25022502-- >>> break_ (< 1) [3,2,1]
25032503-- > ([3,2,1],[])
@@ -2611,7 +2611,7 @@ groups = groupsBy (==)
26112611-- stream before the sequence and the second part consisting of the sequence
26122612-- and the rest of the stream.
26132613--
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
26152615--
26162616-- >>> breakOn_ "dear" "Hello dear world!"
26172617-- > ("Hello ","dear world!")
@@ -2988,7 +2988,7 @@ wordsOn subseq f m = undefined -- D.fromStreamD $ D.wordsOn f subseq (D.toStream
29882988splitBySeq
29892989 :: (IsStream t, MonadAsync m, Storable a, Enum a, Eq a)
29902990 => 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
29922992
29932993-- | Like 'splitSuffixOn' but keeps the suffix intact in the splits.
29942994--
src/Streamly/Prelude.hs+4−4
@@ -186,7 +186,7 @@ module Streamly.Prelude
186186 -- ** Composable Left Folds
187187 -- $runningfolds
188188
189− , runFold
189+ , fold
190190
191191 -- ** Full Folds
192192 -- | Folds that are guaranteed to evaluate the whole stream.
@@ -885,11 +885,11 @@ import Streamly.Internal.Prelude
885885-- $runningfolds
886886--
887887-- "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'.
889889-- The following two ways of folding are equivalent in functionality and
890890-- performance,
891891--
892−-- >>> S.runFold FL.sum (S.enumerateFromTo 1 100)
892+-- >>> S.fold FL.sum (S.enumerateFromTo 1 100)
893893-- 5050
894894-- >>> S.sum (S.enumerateFromTo 1 100)
895895-- 5050
@@ -905,7 +905,7 @@ import Streamly.Internal.Prelude
905905--
906906-- >>> S.head (1 `S.cons` undefined)
907907-- Just 1
908−-- >>> S.runFold FL.head (1 `S.cons` undefined)
908+-- >>> S.fold FL.head (1 `S.cons` undefined)
909909-- *** Exception: Prelude.undefined
910910--
911911-- 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 =
4343 forAll (choose (0, maxArrLen)) $ \len ->
4444 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
4545 monadicIO $ do
46− arr <- S.runFold (A.writeN len)
46+ arr <- S.fold (A.writeN len)
4747 $ S.fromList list
4848 assert (A.length arr == len)
4949
@@ -52,7 +52,7 @@ testFromToStreamN =
5252 forAll (choose (0, maxArrLen)) $ \len ->
5353 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
5454 monadicIO $ do
55− arr <- S.runFold (A.writeN len)
55+ arr <- S.fold (A.writeN len)
5656 $ S.fromList list
5757 xs <- S.toList
5858 $ A.read arr
@@ -63,7 +63,7 @@ testToStreamRev =
6363 forAll (choose (0, maxArrLen)) $ \len ->
6464 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
6565 monadicIO $ do
66− arr <- S.runFold (A.writeN len)
66+ arr <- S.fold (A.writeN len)
6767 $ S.fromList list
6868 xs <- S.toList
6969 $ A.readRev arr
@@ -96,7 +96,7 @@ testFromToStream =
9696 forAll (choose (0, maxArrLen)) $ \len ->
9797 forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
9898 monadicIO $ do
99− arr <- S.runFold A.write $ S.fromList list
99+ arr <- S.fold A.write $ S.fromList list
100100 xs <- S.toList
101101 $ A.read arr
102102 assert (xs == list)
test/String.hs+1−1
@@ -57,7 +57,7 @@ propDecodeEncodeIdArrays =
5757 monadicIO $ do
5858 let wrds = SS.encodeUtf8 $ S.fromList list
5959 chrs <- S.toList $ SS.decodeUtf8ArraysLenient
60− (S.runFold A.write wrds)
60+ (S.fold A.write wrds)
6161 assert (chrs == list)
6262
6363testLines :: Property