O(n), where
n is the length of the result. The
unfoldr function is analogous to the List 'unfoldr'.
unfoldr builds a ShortByteString from a seed value. The
function takes the element and returns
Nothing if it is done
producing the ShortByteString or returns
Just (a,b),
in which case,
a is the next byte in the string, and
b is the seed value for further production.
This function is not efficient/safe. It will build a list of
[Word8] and run the generator until it returns
Nothing, otherwise recurse infinitely, then finally create a
ShortByteString.
If you know the maximum length, consider using
unfoldrN.
Examples:
unfoldr (\x -> if x <= 5 then Just (x, x + 1) else Nothing) 0
== pack [0, 1, 2, 3, 4, 5]