data Stream a
A co-recursive type yielding a single element at a time depending on the internal state it carries.
Warning: this is an internal module, and does not have a stable API or name. Functions in this module may not check or enforce preconditions expected by public modules. Use at your own risk!
Text manipulation functions represented as fusible operations over streams.
data Stream aA co-recursive type yielding a single element at a time depending on the internal state it carries.
Stream :: forall s. (s -> Step s a) -> s -> Size -> Stream adata Step s aIntermediate result in a processing pipeline.
Done :: Step s aSkip :: s -> Step s aYield :: a -> s -> Step s astream :: Text -> Stream CharO(n) Convert Text into a Stream Char.
Properties
unstream . stream = id
stream . unstream = id
streamLn :: Text -> Stream CharO(n) streamLn t = stream (t <> '\n')
unstream :: Stream Char -> TextO(n) Convert Stream Char into a Text.
Properties
unstream . stream = id
stream . unstream = id
reverseStream :: Text -> Stream CharO(n) Converts Text into a Stream Char, but iterates
backwards through the text.
Properties
unstream . reverseStream = reverse
length :: Stream Char -> IntO(n) Returns the number of characters in a Stream.
Properties
length . stream = length
reverse :: Stream Char -> TextO(n) Reverse the characters of a Stream returning Text.
Properties
reverse . stream = reverse
reverseScanr :: (Char -> Char -> Char) -> Char -> Stream Char -> Stream CharO(n) Perform the equivalent of scanr over a list, only with
the input and result reversed.
Properties
reverse . reverseScanr f c . reverseStream = scanr f c
mapAccumL :: (a -> Char -> (a, Char)) -> a -> Stream Char -> (a, Text)O(n) Like a combination of map and foldl'. Applies a
function to each element of a Text, passing an accumulating
parameter from left to right, and returns a final Text.
Properties
mapAccumL g z0 . stream = mapAccumL g z0
unfoldrN :: Int -> (a -> Maybe (Char, a)) -> a -> Stream CharO(n) Like unfoldr, unfoldrN builds a stream from a seed
value. However, the length of the result is limited by the
first argument to unfoldrN. This function is more efficient than
unfoldr when the length of the result is known.
Properties
unstream (unfoldrN n f a) = unfoldrN n f a
index :: HasCallStack => Stream Char -> Int -> CharO(n) stream index (subscript) operator, starting from 0.
Properties
index (stream t) n = index t n
findIndex :: (Char -> Bool) -> Stream Char -> Maybe IntThe findIndex function takes a predicate and a stream and
returns the index of the first element in the stream
satisfying the predicate.
Properties
findIndex p . stream = findIndex p
countChar :: Char -> Stream Char -> IntO(n) The count function returns the number of times the query
element appears in the given stream.
Properties
countChar c . stream = countChar c
Community contribution. The service has not verified this documentation. The generator reported 2 diagnostics.
Target: Linux on x86-64. Some inferred types and resolved links are not available.
Generator: aihc-haddock-858b1951-web-1
Metadata snapshot: 0b0724abd14577f7a6c8172d62e3e1c0808feb114d4d379402e17f37e3c7801e
Open the dependency plan · Download the documentation model