@@ -538,22 +538,15 @@ takeWhile f = takeWhileM (return . f)
539{-# INLINE_NORMAL drop #-}
539{-# INLINE_NORMAL drop #-}
540drop :: Monad m => Int -> Stream m a -> Stream m a
540drop :: 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)
543 {-# INLINE_LATE step' #-}
543 {-# INLINE_LATE step' #-}
544− step' gst (st, Just i)
544+ step' gst (st, i) = do
546− r <- step (rstState gst) st
548− Yield _ s -> step' (rstState gst) (s, Just (i - 1))
550− | otherwise = step' gst (st, Nothing)
552− step' gst (st, Nothing) = do
553 r <- step (rstState gst) st
545 r <- step (rstState gst) st
554− return $ case r of
546+ case r of
547+ Yield _ s | i > 0 -> step' gst (s, i - 1)
555− Yield x s -> Yield x (s, Nothing)
548+ Yield x s -> return $ Yield x (s, 0)
556− Stop -> Stop
549+ Stop -> return Stop
558data DropWhileState s a
551data DropWhileState s a
559 = DropWhileDrop s
552 = DropWhileDrop s