@@ -382,7 +382,7 @@ converting them to and from streams.
382382
383383## Folds
384384
385−`Streamly.Fold` module provides composable left folds. A `Fold` is a consumer
385+`Streamly.Data.Fold` module provides composable left folds. A `Fold` is a consumer
386386of a stream. Folds can be used to fold a stream. Folds can be composed in many
387387ways, a stream can be distributed to multiple folds, or it can be partitioned
388388across multiple folds, or demultiplexed over multiple folds, or unzipped to two
@@ -396,9 +396,10 @@ powerful ways of composing and applying them.
396396## File IO
397397
398398The following code snippets implement some common Unix command line utilities
399−using streamly. You can compile these with `ghc -O2
400−-fspec-constr-recursive=10` and compare the performance with regular GNU
401−coreutils available on your system. Source file
399+using streamly. You can compile these with `ghc -O2 -fspec-constr-recursive=10
400+-fmax-worker-args=16` and compare the performance with regular GNU coreutils
401+available on your system. Though many of these are not most optimal solutions
402+to keep them short and elegant. Source file
402403[HandleIO.hs](https://github.com/composewell/streamly/tree/master/examples/HandleIO.hs)
403404in the examples directory includes these examples.
404405
@@ -406,9 +407,8 @@ in the examples directory includes these examples.
406407module Main where
407408
408409import qualified Streamly.Prelude as S
409−import qualified Streamly.Fold as FL
410+import qualified Streamly.Data.Fold as FL
410411import qualified Streamly.Memory.Array as A
411−import qualified Streamly.Memory.ArrayStream as AS
412412import qualified Streamly.FileSystem.Handle as FH
413413import qualified System.IO as FH
414414
@@ -431,31 +431,31 @@ withArg2 f = do
431431### cat
432432
433433``` haskell
434−cat = S.runFold (FH.writeArrays stdout) . FH.readArrays
434+cat = S.fold (FH.writeArrays stdout) . S.unfold FH.readArrays
435435main = withArg cat
436436```
437437
438438### cp
439439
440440``` haskell
441−cp src dst = S.runFold (FH.writeArrays dst) $ FH.readArrays src
441+cp src dst = S.fold (FH.writeArrays dst) $ S.unfold FH.readArrays src
442442main = withArg2 cp
443443```
444444
445445### wc -l
446446
447447``` haskell
448−wcl = S.length . AS.splitOn 10 . FH.readArrays
448+wcl = S.length . S.splitOn (== 10) FL.drain . S.unfold FH.read
449449main = withArg wcl >>= print
450450```
451451
452452### Average Line Length
453453
454454``` haskell
455−avgll =
456− S.runFold avg
457− . S.splitWithSuffix (== 10) FL.length
458− . FH.read
455+avgll =
456+ S.fold avg
457+ . S.splitOn (== 10) FL.length
458+ . S.unfold FH.read
459459
460460 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
461461 toDouble = fmap (fromIntegral :: Int -> Double)
@@ -467,10 +467,10 @@ main = withArg avgll >>= print
467467
468468``` haskell
469469llhisto =
470− S.runFold (FL.classify FL.length)
470+ S.fold (FL.classify FL.length)
471471 . S.map bucket
472− . S.splitWithSuffix (== 10) FL.length
473− . FH.read
472+ . S.splitOn (== 10) FL.length
473+ . S.unfold FH.read
474474
475475 where
476476 bucket n = let i = n `div` 10 in if i > 9 then (9,n) else (i,n)