substring search api

Johannes Waldmann waldmann at
Tue Sep 18 12:23:15 EDT 2007

Justin Bailey wrote:

> My use case for searching bytestrings was to determine where a
> particular substring occurred in a search string. Thus, I needed the
> index.

but what for? In a real application, I guess you want to do some further
processing, so the index is just some intermediate result
(you will acccess the string via the index later).

The point now is to remove this intermediate altogether. (Cf. we
don't have pointers - that's what distinguishes Haskell from C).

Yes, space leaks might be a concern, but dangling (int) pointers
are a concern as well: a concern for readability and safeness:

if you have some Int, how do you know which string it points to,
or whether it is a pointer or an offset to a pointer etc.
(whenever I see an int/Int, I sense the "primitive obsession" smell ...)

Best regards, Johannes Waldmann.

More information about the Libraries mailing list