substring search api

Bryan O'Sullivan bos at
Tue Sep 18 14:00:39 EDT 2007

Duncan Coutts wrote:

> So perhaps that's my straw-man proposal:
>   * change BS.findSubstring to be :: BS -> BS -> (BS, BS)
>      in the style of List.break
>   * remove the current BS.findSubstrings

While List.break is useful, it has the equally useful counterpart 
(dropWhile . not . (==)) that doesn't accumulate the prefix of a match. 
  For a long sequence, this has appeal.  Let's say you're reading ten 
gigabytes of data over the network, so you have no control over the 
incoming chunk size (as we don't provide a rechunking mechanism at 
present, so this isn't a hypothetical issue).  A findSubstring that 
accumulates the prefix could easily cons an fatally large number of chunks.

I'm not saying that the signature you suggest shouldn't be present, 
merely that it's not enough: it wants a counterpart that accumulates 
either nothing or something safe like an Int64 that counts the length of 
the prefix.


More information about the Libraries mailing list