@@ -217,9 +217,7 @@ filter isOdd naturals
217217filter isOdd twos
218218```
219219
220−The produced Stream can go into an infinite loop if no more elements
221−satisfy the predicate. So be sure that there are infinitely many terms
222−in the stream that satisfy the predicate.
220+This can infinite loop if no more elements in the stream satisfy the predicate!
223221-}
224222filter : (a -> Bool) -> Stream a -> Stream a
225223filter pred xs = cons' <| (\() ->
@@ -237,12 +235,13 @@ takeWhile (\n -> n < 10) powersOf2 == [2,4,8]
237235-- Bad! Infinite loop!
238236takeWhile isEven powersOf2
239237```
238+
239+This can infinite loop if all elements of the stream satisfy the predicate!
240240-}
241241takeWhile : (a -> Bool) -> Stream a -> [a]
242242takeWhile pred xs = fst <| splitWith pred xs
243243
244244{-| Drop values from the stream as long as the predicate holds.
245−This can infinite loop if all elements of the stream satisfy the predicate!
246245
247246```haskell
248247-- 16, 32, 64, 128, ...
@@ -251,15 +250,22 @@ dropWhile (\n -> n < 10) powersOf2
251250-- Bad! Infinite loop!
252251dropWhile isEven powersOf2
253252```
253+
254+This can infinite loop if all elements of the stream satisfy the predicate!
254255-}
255256dropWhile : (a -> Bool) -> Stream a -> Stream a
256257dropWhile pred xs = snd <| splitWith pred xs
257258
258−{-| Split a stream when a predicate holds and
259−the rest of the Stream. This function only terminates if there is
260−an element of the stream for which the predicate does not hold.
259+{-| Combination of `takeWhile` and `dropWhile`. Split a stream when
260+the predicate no longer holds.
261+
262+```haskell
263+splitWith pred xs == (takeWhile pred xs, dropWhile pred xs)
264+
265+splitWith (\n -> n < 10) powersOf2 == ([2,4,8], ...)
266+```
261267
262− splitWith pred xs == (takeWhile pred xs, dropWhile pred xs)
268+This can infinite loop if all elements satisfy the predicate!
263269-}
264270splitWith : (a -> Bool) -> Stream a -> ([a], Stream a)
265271splitWith pred xs = let (hd, tl) = unS xs in