@@ -44,8 +44,6 @@ The meaning of these types are:
4444 `a` in the IO Monad.
4545* A `Fold IO a b` is a representation of a function that converts a stream of
4646 type `a` to a final accumulator of type `b` in the IO Monad.
47−* An `Unfold IO a b` is a representation of a function that converts a seed
48− value of type `a` into a stream of values of type `b` in the IO Monad.
4947
5048## The Examples
5149
@@ -219,7 +217,7 @@ import qualified Streamly.Unicode.Stream as Unicode
219217
220218countArray :: Array Word8 -> IO Counts
221219countArray arr =
222− Stream.unfold Array.reader arr -- Stream IO Word8
220+ Array.read arr -- Stream IO Word8
223221 & Unicode.decodeLatin1 -- Stream IO Char
224222 & Stream.fold (Fold.foldl' count (Counts 0 0 0 True)) -- IO Counts
225223```
@@ -335,9 +333,9 @@ fetch w = threadDelay 1000000 >> return (w,w)
335333-- connection is closed.
336334lookupWords :: Socket -> IO ()
337335lookupWords sk =
338− Stream.unfold Socket.reader sk -- Stream IO Word8
336+ Socket.read sk -- Stream IO Word8
339337 & Unicode.decodeLatin1 -- Stream IO Char
340− & Stream.parseMany word -- Stream IO String
338+ & Stream.wordsBy isSpace Fold.toList -- Stream IO String
341339 & Stream.parMapM cfg fetch -- Stream IO (String, String)
342340 & fmap show -- Stream IO String
343341 & Stream.intersperse "\n" -- Stream IO String
@@ -346,7 +344,6 @@ lookupWords sk =
346344
347345 where
348346
349− word = Parser.wordBy isSpace Fold.toList
350347 cfg = Stream.ordered True
351348
352349serve :: Socket -> IO ()
@@ -357,9 +354,9 @@ serve sk = finally (lookupWords sk) (close sk)
357354-- "nc" as a client to try it out.
358355main :: IO ()
359356main =
360− Stream.unfold TCP.acceptorOnPort 8091 -- Stream IO Socket
361− & Stream.parMapM id serve -- Stream IO ()
362− & Stream.fold Fold.drain -- IO ()
357+ TCP.accept 8091 -- Stream IO Socket
358+ & Stream.parMapM id serve -- Stream IO ()
359+ & Stream.fold Fold.drain -- IO ()
363360```
364361
365362### Merging Incoming Streams
@@ -379,7 +376,6 @@ including the imports that we have omitted below.
379376import Streamly.Data.Stream (Stream)
380377import System.IO (IOMode(AppendMode), Handle, withFile)
381378
382−import qualified Streamly.Data.Unfold as Unfold
383379import qualified Streamly.Network.Socket as Socket
384380import qualified Streamly.FileSystem.Handle as Handle
385381
@@ -388,9 +384,9 @@ import qualified Streamly.FileSystem.Handle as Handle
388384-- buffering for safety.
389385readLines :: Socket -> Stream IO (Array Char)
390386readLines sk =
391− Stream.unfold Socket.reader sk -- Stream IO Word8
392− & Unicode.decodeLatin1 -- Stream IO Char
393− & Stream.foldMany line -- Stream IO (Array Char)
387+ Socket.read sk -- Stream IO Word8
388+ & Unicode.decodeLatin1 -- Stream IO Char
389+ & Stream.foldMany line -- Stream IO (Array Char)
394390
395391 where
396392
@@ -405,7 +401,7 @@ recv sk = Stream.finallyIO (close sk) (readLines sk)
405401-- streams at line boundaries and writes the merged stream to a file.
406402server :: Handle -> IO ()
407403server file =
408− Stream.unfold TCP.acceptorOnPort 8090 -- Stream IO Socket
404+ TCP.accept 8090 -- Stream IO Socket
409405 & Stream.parConcatMap (Stream.eager True) recv -- Stream IO (Array Char)
410406 & Stream.unfoldMany Array.reader -- Stream IO Char
411407 & Unicode.encodeLatin1 -- Stream IO Word8