@@ -637,7 +637,8 @@ unfoldrNI n f s0 | n < 0 = empty
637-- stream of length @n@, or the stream itself if @n@ is greater than the
637-- stream of length @n@, or the stream itself if @n@ is greater than the
638-- length of the stream.
638-- length of the stream.
639take :: Integral a => a -> Stream Char -> Stream Char
639take :: Integral a => a -> Stream Char -> Stream Char
640+take n0 (Stream next0 s0 len) =
640−take n0 (Stream next0 s0 len) = Stream next (n0 :!: s0) (min 0 (len - fromIntegral n0)) -- HINT maybe too high
641+ Stream next (n0 :!: s0) (max 0 (len - fromIntegral n0)) -- HINT maybe too high
642 {-# INLINE next #-}
643 {-# INLINE next #-}
643 next (n :!: s) | n <= 0 = Done
644 next (n :!: s) | n <= 0 = Done