on master help sign in
Add documentation for iterate
commit4a6f946319de03a344d01485d0333445f6aeb7ab authorAbhiroop Sarkar <asiamgenius@gmail.com> dateThu 22 Mar 2018, 21:51 (9 years ago) parent3d12532
1 file changed+4−2
src/Streamly/Prelude.hs+4−2
src/Streamly/Prelude.hs+4−2
@@ -122,10 +122,12 @@ unfoldrM step = fromStream . go
122122each :: (Streaming t, Foldable f) => f a -> t m a
123123each = Prelude.foldr cons nil
124124
125+-- | Iterate a pure function from a seed value, streaming the results forever
125126iterate :: Streaming t => (a -> a) -> a -> t m a
126−iterate f = fromStream . go
127+iterate step = fromStream . go
127128 where
128− go s = scons s (Just (go (f s)))
129+ go s = scons s (Just (go (step s)))
130+
129131
130132-- | Read lines from an IO Handle into a stream of Strings.
131133fromHandle :: (Streaming t, MonadIO m) => IO.Handle -> t m String