Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use forever for repeatM #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/Streaming/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ elem_ a' = loop False where
It is the same as @S.iterate succ@.
Because their return type is polymorphic, @enumFrom@, @enumFromThen@
and @iterate@ are useful with functions like @zip@ and @zipWith@, which
require the zipped streams to have the same return type.
require the zipped streams to have the same return type.

For example, with
@each [1..]@ the following bit of connect-and-resume would not compile:
Expand Down Expand Up @@ -1390,7 +1390,7 @@ mapM_ f = loop where


{- | Map layers of one functor to another with a transformation involving the base monad.

This function is completely functor-general. It is often useful with the more concrete type

@
Expand Down Expand Up @@ -1706,11 +1706,8 @@ two<Enter>
-}

repeatM :: Monad m => m a -> Stream (Of a) m r
repeatM ma = loop where
loop = do
a <- lift ma
yield a
loop
repeatM ma = forever (lift ma >>= yield)

{-# INLINABLE repeatM #-}

-- ---------------
Expand Down