eof package:streamly-core

Succeeds if we are at the end of input, fails otherwise.
>>> Stream.parse ((,) <$> Parser.satisfy (> 0) <*> Parser.eof) $ Stream.fromList [1]
Right (1,())
createOf n folds a maximum of n elements from the input stream to an Array.
Get the size. Size cannot be zero, should be at least 1 byte.
Get the size. Size cannot be zero, should be at least 1 byte.
createOf n folds a maximum of n elements from the input stream to an MutArray.
>>> createOf = MutArray.createOfWith MutArray.new

>>> createOf n = Fold.take n (MutArray.unsafeCreateOf n)

>>> createOf n = MutArray.appendN n (MutArray.emptyOf n)
createOf n folds a maximum of n elements from the input stream to an Array.
>>> createOf n = Fold.take n (MutArray.unsafeCreateOf n)
Pre-release
See performance notes in oneOf.
>>> noneOf xs = Parser.satisfy (`Foldable.notElem` xs)
Match any one of the elements in the supplied list.
>>> oneOf xs = Parser.satisfy (`Foldable.elem` xs)
When performance matters a pattern matching predicate could be more efficient than a Foldable datatype:
let p x =
case x of
a -> True
e -> True
_  -> False
in satisfy p
GHC may use a binary search instead of linear search in the list. Alternatively, you can also use an array instead of list for storage and search.
Returns True if all the elements of the first stream occur, in order, in the second stream. The elements do not have to occur consecutively. A stream is a subsequence of itself.
>>> Stream.isSubsequenceOf (Stream.fromList "hlo") (Stream.fromList "hello" :: Stream IO Char)
True
Like createOf but creates a pinned array.
Like createOf but does not check the array bounds when writing. The fold driver must not call the step function more than n times otherwise it will corrupt the memory and crash. This function exists mainly because any conditional in the step function blocks fusion causing 10x performance slowdown.
createOfWith alloc n folds a maximum of n elements into an array allocated using the alloc function.
>>> createOfWith alloc n = Fold.take n (MutArray.unsafeCreateOfWith alloc n)

>>> createOfWith alloc n = MutArray.appendN (alloc n) n
Like createOf but creates a pinned array.
Like createOf but writes the array in reverse order. Pre-release
Like createOf but does not check the array bounds when writing. The fold driver must not call the step function more than n times otherwise it will corrupt the memory and crash. This function exists mainly because any conditional in the step function blocks fusion causing 10x performance slowdown.
>>> unsafeCreateOf = MutArray.unsafeCreateOfWith MutArray.emptyOf
Like unsafeCreateOf but takes a new array allocator alloc size function as argument.
>>> unsafeCreateOfWith alloc n = MutArray.unsafeAppendN (alloc n) n
Pre-release
Like unsafeCreateOf but creates a pinned array.
Like createOf but does not check the array bounds when writing. The fold driver must not call the step function more than n times otherwise it will corrupt the memory and crash. This function exists mainly because any conditional in the step function blocks fusion causing 10x performance slowdown. Pre-release
Implementation of sizeOf that works on the generic representation of an ADT.
Return the size of the array in bytes.