@@ -538,22 +538,15 @@ takeWhile f = takeWhileM (return . f)
538538
539539{-# INLINE_NORMAL drop #-}
540540drop :: Monad m => Int -> Stream m a -> Stream m a
541−drop n (Stream step state) = Stream step' (state, Just n)
541+drop n (Stream step state) = Stream step' (state, n)
542542 where
543543 {-# INLINE_LATE step' #-}
544− step' gst (st, Just i)
545− | i > 0 = do
546− r <- step (rstState gst) st
547− case r of
548− Yield _ s -> step' (rstState gst) (s, Just (i - 1))
549− Stop -> return Stop
550− | otherwise = step' gst (st, Nothing)
551−
552− step' gst (st, Nothing) = do
544+ step' gst (st, i) = do
553545 r <- step (rstState gst) st
554− return $ case r of
555− Yield x s -> Yield x (s, Nothing)
556− Stop -> Stop
546+ case r of
547+ Yield _ s | i > 0 -> step' gst (s, i - 1)
548+ Yield x s -> return $ Yield x (s, 0)
549+ Stop -> return Stop
557550
558551data DropWhileState s a
559552 = DropWhileDrop s