@@ -24,6 +24,7 @@ module Streamly.Prelude
25 , unfoldrM
25 , unfoldrM
28 -- * Elimination
29 -- * Elimination
29 -- ** General Folds
30 -- ** General Folds
@@ -85,7 +86,8 @@ import Prelude hiding (filter, drop, dropWhile, take,
85 mapM, mapM_, sequence, all, any,
86 mapM, mapM_, sequence, all, any,
86 sum, product, elem, notElem,
87 sum, product, elem, notElem,
87 maximum, minimum, head, last,
88 maximum, minimum, head, last,
88− tail, length, null, reverse)
89+ tail, length, null, reverse,
89import qualified Prelude
91import qualified Prelude
90import qualified System.IO as IO
92import qualified System.IO as IO
@@ -120,6 +122,11 @@ unfoldrM step = fromStream . go
120each :: (Streaming t, Foldable f) => f a -> t m a
122each :: (Streaming t, Foldable f) => f a -> t m a
121each = Prelude.foldr cons nil
123each = Prelude.foldr cons nil
125+iterate :: Streaming t => (a -> a) -> a -> t m a
126+iterate f = fromStream . go
128+ go s = scons s (Just (go (f s)))
123-- | Read lines from an IO Handle into a stream of Strings.
130-- | Read lines from an IO Handle into a stream of Strings.
124fromHandle :: (Streaming t, MonadIO m) => IO.Handle -> t m String
131fromHandle :: (Streaming t, MonadIO m) => IO.Handle -> t m String
125fromHandle h = fromStream go
132fromHandle h = fromStream go