break package:streaming

Break a sequence upon meeting element falls under a predicate, keeping it and the rest of the stream as the return value.
>>> rest <- S.print $ S.break even $ each [1,1,2,3]
1
1

>>> S.print rest
2
3
Yield elements, using a fold to maintain state, until the accumulated value satifies the supplied predicate. The fold will then be short-circuited and the element that breaks it will be put after the break. This function is easiest to use with purely
>>> rest <- each [1..10] & L.purely S.breakWhen L.sum (>10) & S.print
1
2
3
4

>>> S.print rest
5
6
7
8
9
10
Break during periods where the predicate is not satisfied, grouping the periods when it is.
>>> S.print $ mapped S.toList $ S.breaks not $ S.each [False,True,True,False,True,True,False]
[True,True]
[True,True]

>>> S.print $ mapped S.toList $ S.breaks id $ S.each [False,True,True,False,True,True,False]
[False]
[False]
[False]