@@ -167,13 +167,13 @@ foldr step acc m = go (toStream m)
168-- | Right fold with a monadic step function. See 'toList' for an example use.
168-- | Right fold with a monadic step function. See 'toList' for an example use.
169{-# INLINE foldrM #-}
169{-# INLINE foldrM #-}
170−foldrM :: Streaming t => (a -> m b -> m b) -> m b -> t m a -> m b
170+foldrM :: (Streaming t, Monad m) => (a -> b -> m b) -> b -> t m a -> m b
171foldrM step acc m = go (toStream m)
171foldrM step acc m = go (toStream m)
174− let stop = acc
174+ let stop = return acc
175 yield a Nothing = step a acc
175 yield a Nothing = step a acc
176− yield a (Just x) = step a (go x)
176+ yield a (Just x) = (go x) >>= (step a)
177 in (runStream m1) Nothing stop yield
177 in (runStream m1) Nothing stop yield
179-- | Scan left. A strict left fold which accumulates the result of its reduction steps inside a stream, from left.
179-- | Scan left. A strict left fold which accumulates the result of its reduction steps inside a stream, from left.
@@ -255,7 +255,7 @@ toHandle h m = go (toStream m)
255-- | Convert a stream into a list in the underlying monad.
255-- | Convert a stream into a list in the underlying monad.
256{-# INLINABLE toList #-}
256{-# INLINABLE toList #-}
257toList :: (Streaming t, Monad m) => t m a -> m [a]
257toList :: (Streaming t, Monad m) => t m a -> m [a]
258−toList = foldrM (\a xs -> fmap (a :) xs) (return [])
258+toList = foldrM (\a xs -> return (a : xs)) []
260-- | Take first 'n' elements from the stream and discard the rest.
260-- | Take first 'n' elements from the stream and discard the rest.
261{-# INLINE take #-}
261{-# INLINE take #-}