This file is indexed.

/usr/share/doc/libghc-stringsearch-doc/html/stringsearch.txt is in libghc-stringsearch-doc 0.3.6.4-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Fast searching, splitting and replacing of ByteStrings
--   
--   This package provides several functions to quickly search for
--   substrings in strict or lazy ByteStrings. It also provides functions
--   for breaking or splitting on substrings and replacing all occurrences
--   of a substring (the first in case of overlaps) with another. GHC
--   before 6.10 are no longer supported, other compilers only if they
--   support BangPatterns. If you need it to work with other compilers,
--   send a feature request.
@package stringsearch
@version 0.3.6.4


-- | Simultaneous search for multiple patterns in a lazy <a>ByteString</a>
--   using the Karp-Rabin algorithm.
--   
--   A description of the algorithm for a single pattern can be found at
--   <a>http://www-igm.univ-mlv.fr/~lecroq/string/node5.html#SECTION0050</a>.
module Data.ByteString.Lazy.Search.KarpRabin

-- | <tt><a>indicesOfAny</a></tt> finds all occurrences of any of several
--   non-empty strict patterns in a lazy target string. If no non-empty
--   patterns are given, the result is an empty list. Otherwise the result
--   list contains the pairs of all indices where any of the (non-empty)
--   patterns start and the list of all patterns starting at that index,
--   the patterns being represented by their (zero-based) position in the
--   pattern list. Empty patterns are filtered out before processing
--   begins.
indicesOfAny :: [ByteString] -> ByteString -> [(Int64, [Int])]


-- | Simultaneous search for multiple patterns in a strict
--   <a>ByteString</a> using the Karp-Rabin algorithm.
--   
--   A description of the algorithm for a single pattern can be found at
--   <a>http://www-igm.univ-mlv.fr/~lecroq/string/node5.html#SECTION0050</a>.
module Data.ByteString.Search.KarpRabin

-- | <tt><a>indicesOfAny</a></tt> finds all occurrences of any of several
--   non-empty patterns in a strict target string. If no non-empty patterns
--   are given, the result is an empty list. Otherwise the result list
--   contains the pairs of all indices where any of the (non-empty)
--   patterns start and the list of all patterns starting at that index,
--   the patterns being represented by their (zero-based) position in the
--   pattern list. Empty patterns are filtered out before processing
--   begins.
indicesOfAny :: [ByteString] -> ByteString -> [(Int, [Int])]


-- | Fast search of strict <a>ByteString</a> values using the
--   Knuth-Morris-Pratt algorithm.
--   
--   A description of the algorithm can be found at
--   <a>http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm</a>.
--   
--   Original authors: Justin Bailey (jgbailey at gmail.com) and Chris
--   Kuklewicz (haskell at list.mightyreason.com).
module Data.ByteString.Search.KMP

-- | <tt><a>indices</a></tt> finds the starting indices of all possibly
--   overlapping occurrences of the pattern in the target string. If the
--   pattern is empty, the result is <tt>[0 .. <a>length</a> target]</tt>.
indices :: ByteString -> ByteString -> [Int]

-- | <tt><a>nonOverlappingIndices</a></tt> finds the starting indices of
--   all non-overlapping occurrences of the pattern in the target string.
--   It is more efficient than removing indices from the list produced by
--   <a>indices</a>.
nonOverlappingIndices :: ByteString -> ByteString -> [Int]


-- | Fast non-overlapping Knuth-Morris-Pratt search of both strict and lazy
--   <a>ByteString</a> values.
--   
--   A description of the algorithm can be found at
--   <a>http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm</a>.
--   
--   Original authors: Justin Bailey (jgbailey at gmail.com) and Chris
--   Kuklewicz (haskell at list.mightyreason.com).

-- | <i>Deprecated: Use the new interface instead </i>
module Data.ByteString.Search.KnuthMorrisPratt

-- | <tt><a>matchLL</a></tt> finds the starting indices of all
--   <i>non-overlapping</i> occurrences of the pattern in the target
--   string. It is a simple wrapper around <a>nonOverlappingIndices</a>
--   strictifying the pattern.
matchLL :: ByteString -> ByteString -> [Int64]

-- | <tt><a>matchLS</a></tt> finds the starting indices of all
--   <i>non-overlapping</i> occurrences of the pattern in the target
--   string. It is a simple wrapper around <a>nonOverlappingIndices</a>
--   strictifying the pattern.
matchLS :: ByteString -> ByteString -> [Int]

-- | <tt><a>matchSS</a></tt> finds the starting indices of all
--   <i>non-overlapping</i> occurrences of the pattern in the target
--   string. It is an alias for <a>nonOverlappingIndices</a>.
matchSS :: ByteString -> ByteString -> [Int]

-- | <tt><a>matchSL</a></tt> finds the starting indices of all
--   <i>non-overlapping</i> occurrences of the pattern in the target
--   string. It is an alias for <a>nonOverlappingIndices</a>.
matchSL :: ByteString -> ByteString -> [Int64]


-- | Fast search of lazy <a>ByteString</a> values using the
--   Knuth-Morris-Pratt algorithm.
--   
--   A description of the algorithm can be found at
--   <a>http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm</a>.
--   
--   Original authors: Justin Bailey (jgbailey at gmail.com) and Chris
--   Kuklewicz (haskell at list.mightyreason.com).
module Data.ByteString.Lazy.Search.KMP

-- | <tt><a>indices</a></tt> finds the starting indices of all possibly
--   overlapping occurrences of the pattern in the target string. If the
--   pattern is empty, the result is <tt>[0 .. <a>length</a> target]</tt>.
indices :: ByteString -> ByteString -> [Int64]

-- | <tt><a>nonOverlappingIndices</a></tt> finds the starting indices of
--   all non-overlapping occurrences of the pattern in the target string.
--   It is more efficient than removing indices from the list produced by
--   <a>indices</a>.
nonOverlappingIndices :: ByteString -> ByteString -> [Int64]

-- | <tt><a>strictify</a></tt> transforms a lazy <a>ByteString</a> into a
--   strict <a>ByteString</a>, to make it a suitable pattern for the
--   searching functions.
strictify :: ByteString -> ByteString


-- | Class for values to be substituted into strict and lazy
--   <a>ByteString</a>s by the <tt>replace</tt> functions defined in this
--   package.
module Data.ByteString.Search.Substitution

-- | Type class of meaningful substitutions for replace functions on
--   ByteStrings. Instances for strict and lazy ByteStrings are provided
--   here.
class Substitution a
substitution :: Substitution a => a -> ([ByteString] -> [ByteString])
prependCycle :: Substitution a => a -> (ByteString -> ByteString)
instance Substitution ByteString
instance Substitution ByteString


-- | Fast search of strict <a>ByteString</a> values. Breaking, splitting
--   and replacing using a deterministic finite automaton.
module Data.ByteString.Search.DFA

-- | <tt><a>indices</a></tt> finds the starting indices of all possibly
--   overlapping occurrences of the pattern in the target string. If the
--   pattern is empty, the result is <tt>[0 .. <a>length</a> target]</tt>.
indices :: ByteString -> ByteString -> [Int]

-- | <tt><a>nonOverlappingIndices</a></tt> finds the starting indices of
--   all non-overlapping occurrences of the pattern in the target string.
--   It is more efficient than removing indices from the list produced by
--   <a>indices</a>.
nonOverlappingIndices :: ByteString -> ByteString -> [Int]

-- | <tt><a>breakOn</a> pattern target</tt> splits <tt>target</tt> at the
--   first occurrence of <tt>pattern</tt>. If the pattern does not occur in
--   the target, the second component of the result is empty, otherwise it
--   starts with <tt>pattern</tt>. If the pattern is empty, the first
--   component is empty.
--   
--   <pre>
--   <a>uncurry</a> <a>append</a> . <a>breakOn</a> pattern = <a>id</a>
--   </pre>
breakOn :: ByteString -> ByteString -> (ByteString, ByteString)

-- | <tt><a>breakAfter</a> pattern target</tt> splits <tt>target</tt>
--   behind the first occurrence of <tt>pattern</tt>. An empty second
--   component means that either the pattern does not occur in the target
--   or the first occurrence of pattern is at the very end of target. To
--   discriminate between those cases, use e.g. <a>isSuffixOf</a>.
--   
--   <pre>
--   <a>uncurry</a> <a>append</a> . <a>breakAfter</a> pattern = <a>id</a>
--   </pre>
breakAfter :: ByteString -> ByteString -> (ByteString, ByteString)

-- | <tt><a>replace</a> pat sub text</tt> replaces all (non-overlapping)
--   occurrences of <tt>pat</tt> in <tt>text</tt> with <tt>sub</tt>. If
--   occurrences of <tt>pat</tt> overlap, the first occurrence that does
--   not overlap with a replaced previous occurrence is substituted.
--   Occurrences of <tt>pat</tt> arising from a substitution will not be
--   substituted. For example:
--   
--   <pre>
--   <a>replace</a> "ana" "olog" "banana" = "bologna"
--   <a>replace</a> "ana" "o" "bananana" = "bono"
--   <a>replace</a> "aab" "abaa" "aaabb" = "aabaab"
--   </pre>
--   
--   The result is a <i>lazy</i> <a>ByteString</a>, which is lazily
--   produced, without copying. Equality of pattern and substitution is not
--   checked, but
--   
--   <pre>
--   <a>concat</a> . <a>toChunks</a> $ <a>replace</a> pat pat text == text
--   </pre>
--   
--   holds. If the pattern is empty but not the substitution, the result is
--   equivalent to (were they <a>String</a>s) <tt><a>cycle</a> sub</tt>.
--   
--   For non-empty <tt>pat</tt> and <tt>sub</tt> a strict
--   <a>ByteString</a>,
--   
--   <pre>
--   <a>fromChunks</a> . <a>intersperse</a> sub . <a>split</a> pat = <a>replace</a> pat sub
--   </pre>
--   
--   and analogous relations hold for other types of <tt>sub</tt>.
replace :: Substitution rep => ByteString -> rep -> ByteString -> ByteString

-- | <tt><a>split</a> pattern target</tt> splits <tt>target</tt> at each
--   (non-overlapping) occurrence of <tt>pattern</tt>, removing
--   <tt>pattern</tt>. If <tt>pattern</tt> is empty, the result is an
--   infinite list of empty <a>ByteString</a>s, if <tt>target</tt> is empty
--   but not <tt>pattern</tt>, the result is an empty list, otherwise the
--   following relations hold:
--   
--   <pre>
--   <a>concat</a> . <a>intersperse</a> pat . <a>split</a> pat = <a>id</a>,
--   <a>length</a> (<a>split</a> pattern target) ==
--               <a>length</a> (<a>nonOverlappingIndices</a> pattern target) + 1,
--   </pre>
--   
--   no fragment in the result contains an occurrence of <tt>pattern</tt>.
split :: ByteString -> ByteString -> [ByteString]

-- | <tt><a>splitKeepEnd</a> pattern target</tt> splits <tt>target</tt>
--   after each (non-overlapping) occurrence of <tt>pattern</tt>. If
--   <tt>pattern</tt> is empty, the result is an infinite list of empty
--   <a>ByteString</a>s, otherwise the following relations hold:
--   
--   <pre>
--   <a>concat</a> . <a>splitKeepEnd</a> pattern = <a>id</a>,
--   </pre>
--   
--   all fragments in the result except possibly the last end with
--   <tt>pattern</tt>, no fragment contains more than one occurrence of
--   <tt>pattern</tt>.
splitKeepEnd :: ByteString -> ByteString -> [ByteString]

-- | <tt><a>splitKeepFront</a></tt> is like <a>splitKeepEnd</a>, except
--   that <tt>target</tt> is split before each occurrence of
--   <tt>pattern</tt> and hence all fragments with the possible exception
--   of the first begin with <tt>pattern</tt>. No fragment contains more
--   than one non-overlapping occurrence of <tt>pattern</tt>.
splitKeepFront :: ByteString -> ByteString -> [ByteString]


-- | Fast overlapping Boyer-Moore search of lazy <a>ByteString</a> values.
--   Breaking, splitting and replacing using the Boyer-Moore algorithm.
--   
--   Descriptions of the algorithm can be found at
--   <a>http://www-igm.univ-mlv.fr/~lecroq/string/node14.html#SECTION00140</a>
--   and
--   <a>http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm</a>
--   
--   Original authors: Daniel Fischer (daniel.is.fischer at googlemail.com)
--   and Chris Kuklewicz (haskell at list.mightyreason.com).
module Data.ByteString.Lazy.Search

-- | <tt><a>indices</a></tt> finds the starting indices of all possibly
--   overlapping occurrences of the pattern in the target string. If the
--   pattern is empty, the result is <tt>[0 .. <a>length</a> target]</tt>.
indices :: ByteString -> ByteString -> [Int64]

-- | <tt><a>nonOverlappingIndices</a></tt> finds the starting indices of
--   all non-overlapping occurrences of the pattern in the target string.
--   It is more efficient than removing indices from the list produced by
--   <a>indices</a>.
nonOverlappingIndices :: ByteString -> ByteString -> [Int64]

-- | <tt><a>breakOn</a> pattern target</tt> splits <tt>target</tt> at the
--   first occurrence of <tt>pattern</tt>. If the pattern does not occur in
--   the target, the second component of the result is empty, otherwise it
--   starts with <tt>pattern</tt>. If the pattern is empty, the first
--   component is empty. For a non-empty pattern, the first component is
--   generated lazily, thus the first parts of it can be available before
--   the pattern has been found or determined to be absent.
--   
--   <pre>
--   <a>uncurry</a> <a>append</a> . <a>breakOn</a> pattern = <a>id</a>
--   </pre>
breakOn :: ByteString -> ByteString -> (ByteString, ByteString)

-- | <tt><a>breakAfter</a> pattern target</tt> splits <tt>target</tt>
--   behind the first occurrence of <tt>pattern</tt>. An empty second
--   component means that either the pattern does not occur in the target
--   or the first occurrence of pattern is at the very end of target. If
--   you need to discriminate between those cases, use breakFindAfter. If
--   the pattern is empty, the first component is empty. For a non-empty
--   pattern, the first component is generated lazily, thus the first parts
--   of it can be available before the pattern has been found or determined
--   to be absent.
--   
--   <pre>
--   <a>uncurry</a> <a>append</a> . <a>breakAfter</a> pattern = <a>id</a>
--   </pre>
breakAfter :: ByteString -> ByteString -> (ByteString, ByteString)

-- | <tt><a>breakFindAfter</a></tt> does the same as <a>breakAfter</a> but
--   additionally indicates whether the pattern is present in the target.
--   
--   <pre>
--   <a>fst</a> . <a>breakFindAfter</a> pat = <a>breakAfter</a> pat
--   </pre>
breakFindAfter :: ByteString -> ByteString -> ((ByteString, ByteString), Bool)

-- | <tt><a>replace</a> pat sub text</tt> replaces all (non-overlapping)
--   occurrences of <tt>pat</tt> in <tt>text</tt> with <tt>sub</tt>. If
--   occurrences of <tt>pat</tt> overlap, the first occurrence that does
--   not overlap with a replaced previous occurrence is substituted.
--   Occurrences of <tt>pat</tt> arising from a substitution will not be
--   substituted. For example:
--   
--   <pre>
--   <a>replace</a> "ana" "olog" "banana" = "bologna"
--   <a>replace</a> "ana" "o" "bananana" = "bono"
--   <a>replace</a> "aab" "abaa" "aaabb" = "aabaab"
--   </pre>
--   
--   The result is a lazy <a>ByteString</a>, which is lazily produced,
--   without copying. Equality of pattern and substitution is not checked,
--   but
--   
--   <pre>
--   <a>replace</a> pat pat text == text
--   </pre>
--   
--   holds (the internal structure is generally different). If the pattern
--   is empty but not the substitution, the result is equivalent to (were
--   they <a>String</a>s) <tt>cycle sub</tt>.
--   
--   For non-empty <tt>pat</tt> and <tt>sub</tt> a lazy <a>ByteString</a>,
--   
--   <pre>
--   <a>concat</a> . <a>intersperse</a> sub . <a>split</a> pat = <a>replace</a> pat sub
--   </pre>
--   
--   and analogous relations hold for other types of <tt>sub</tt>.
replace :: Substitution rep => ByteString -> rep -> ByteString -> ByteString

-- | <tt><a>split</a> pattern target</tt> splits <tt>target</tt> at each
--   (non-overlapping) occurrence of <tt>pattern</tt>, removing
--   <tt>pattern</tt>. If <tt>pattern</tt> is empty, the result is an
--   infinite list of empty <a>ByteString</a>s, if <tt>target</tt> is empty
--   but not <tt>pattern</tt>, the result is an empty list, otherwise the
--   following relations hold (where <tt>patL</tt> is the lazy
--   <a>ByteString</a> corresponding to <tt>pat</tt>):
--   
--   <pre>
--   <a>concat</a> . <a>intersperse</a> patL . <a>split</a> pat = <a>id</a>,
--   <a>length</a> (<a>split</a> pattern target) ==
--               <a>length</a> (<a>nonOverlappingIndices</a> pattern target) + 1,
--   </pre>
--   
--   no fragment in the result contains an occurrence of <tt>pattern</tt>.
split :: ByteString -> ByteString -> [ByteString]

-- | <tt><a>splitKeepEnd</a> pattern target</tt> splits <tt>target</tt>
--   after each (non-overlapping) occurrence of <tt>pattern</tt>. If
--   <tt>pattern</tt> is empty, the result is an infinite list of empty
--   <a>ByteString</a>s, otherwise the following relations hold:
--   
--   <pre>
--   <a>concat</a> . <a>splitKeepEnd</a> pattern = <a>id</a>,
--   </pre>
--   
--   all fragments in the result except possibly the last end with
--   <tt>pattern</tt>, no fragment contains more than one occurrence of
--   <tt>pattern</tt>.
splitKeepEnd :: ByteString -> ByteString -> [ByteString]

-- | <tt><a>splitKeepFront</a></tt> is like <a>splitKeepEnd</a>, except
--   that <tt>target</tt> is split before each occurrence of
--   <tt>pattern</tt> and hence all fragments with the possible exception
--   of the first begin with <tt>pattern</tt>. No fragment contains more
--   than one non-overlapping occurrence of <tt>pattern</tt>.
splitKeepFront :: ByteString -> ByteString -> [ByteString]

-- | <tt><a>strictify</a></tt> converts a lazy <a>ByteString</a> to a
--   strict <a>ByteString</a> to make it a suitable pattern.
strictify :: ByteString -> ByteString


-- | Fast search of lazy <a>ByteString</a> values. Breaking, splitting and
--   replacing using a deterministic finite automaton.
module Data.ByteString.Lazy.Search.DFA

-- | <tt><a>indices</a></tt> finds the starting indices of all possibly
--   overlapping occurrences of the pattern in the target string. If the
--   pattern is empty, the result is <tt>[0 .. <a>length</a> target]</tt>.
indices :: ByteString -> ByteString -> [Int64]

-- | <tt><a>nonOverlappingIndices</a></tt> finds the starting indices of
--   all non-overlapping occurrences of the pattern in the target string.
--   It is more efficient than removing indices from the list produced by
--   <a>indices</a>.
nonOverlappingIndices :: ByteString -> ByteString -> [Int64]

-- | <tt><a>breakOn</a> pattern target</tt> splits <tt>target</tt> at the
--   first occurrence of <tt>pattern</tt>. If the pattern does not occur in
--   the target, the second component of the result is empty, otherwise it
--   starts with <tt>pattern</tt>. If the pattern is empty, the first
--   component is empty. For a non-empty pattern, the first component is
--   generated lazily, thus the first parts of it can be available before
--   the pattern has been found or determined to be absent.
--   
--   <pre>
--   <a>uncurry</a> <a>append</a> . <a>breakOn</a> pattern = <a>id</a>
--   </pre>
breakOn :: ByteString -> ByteString -> (ByteString, ByteString)

-- | <tt><a>breakAfter</a> pattern target</tt> splits <tt>target</tt>
--   behind the first occurrence of <tt>pattern</tt>. An empty second
--   component means that either the pattern does not occur in the target
--   or the first occurrence of pattern is at the very end of target. If
--   you need to discriminate between those cases, use breakFindAfter. If
--   the pattern is empty, the first component is empty. For a non-empty
--   pattern, the first component is generated lazily, thus the first parts
--   of it can be available before the pattern has been found or determined
--   to be absent. <tt> <a>uncurry</a> <a>append</a> . <a>breakAfter</a>
--   pattern = <a>id</a> </tt>
breakAfter :: ByteString -> ByteString -> (ByteString, ByteString)

-- | <tt><a>breakFindAfter</a></tt> does the same as <a>breakAfter</a> but
--   additionally indicates whether the pattern is present in the target.
--   
--   <pre>
--   <a>fst</a> . <a>breakFindAfter</a> pat = <a>breakAfter</a> pat
--   </pre>
breakFindAfter :: ByteString -> ByteString -> ((ByteString, ByteString), Bool)

-- | <tt><a>replace</a> pat sub text</tt> replaces all (non-overlapping)
--   occurrences of <tt>pat</tt> in <tt>text</tt> with <tt>sub</tt>. If
--   occurrences of <tt>pat</tt> overlap, the first occurrence that does
--   not overlap with a replaced previous occurrence is substituted.
--   Occurrences of <tt>pat</tt> arising from a substitution will not be
--   substituted. For example:
--   
--   <pre>
--   <a>replace</a> "ana" "olog" "banana" = "bologna"
--   <a>replace</a> "ana" "o" "bananana" = "bono"
--   <a>replace</a> "aab" "abaa" "aaabb" = "aabaab"
--   </pre>
--   
--   The result is a lazy <a>ByteString</a>, which is lazily produced,
--   without copying. Equality of pattern and substitution is not checked,
--   but
--   
--   <pre>
--   <a>replace</a> pat pat text == text
--   </pre>
--   
--   holds (the internal structure is generally different). If the pattern
--   is empty but not the substitution, the result is equivalent to (were
--   they <a>String</a>s) <tt>cycle sub</tt>.
--   
--   For non-empty <tt>pat</tt> and <tt>sub</tt> a lazy <a>ByteString</a>,
--   
--   <pre>
--   <a>concat</a> . <a>intersperse</a> sub . <a>split</a> pat = <a>replace</a> pat sub
--   </pre>
--   
--   and analogous relations hold for other types of <tt>sub</tt>.
replace :: Substitution rep => ByteString -> rep -> ByteString -> ByteString

-- | <tt><a>split</a> pattern target</tt> splits <tt>target</tt> at each
--   (non-overlapping) occurrence of <tt>pattern</tt>, removing
--   <tt>pattern</tt>. If <tt>pattern</tt> is empty, the result is an
--   infinite list of empty <a>ByteString</a>s, if <tt>target</tt> is empty
--   but not <tt>pattern</tt>, the result is an empty list, otherwise the
--   following relations hold (where <tt>patL</tt> is the lazy
--   <a>ByteString</a> corresponding to <tt>pat</tt>):
--   
--   <pre>
--   <a>concat</a> . <a>intersperse</a> patL . <a>split</a> pat = <a>id</a>,
--   <a>length</a> (<a>split</a> pattern target) ==
--               <a>length</a> (<a>nonOverlappingIndices</a> pattern target) + 1,
--   </pre>
--   
--   no fragment in the result contains an occurrence of <tt>pattern</tt>.
split :: ByteString -> ByteString -> [ByteString]

-- | <tt><a>splitKeepEnd</a> pattern target</tt> splits <tt>target</tt>
--   after each (non-overlapping) occurrence of <tt>pattern</tt>. If
--   <tt>pattern</tt> is empty, the result is an infinite list of empty
--   <a>ByteString</a>s, otherwise the following relations hold:
--   
--   <pre>
--   <a>concat</a> . <a>splitKeepEnd</a> pattern = 'id,'
--   </pre>
--   
--   all fragments in the result except possibly the last end with
--   <tt>pattern</tt>, no fragment contains more than one occurrence of
--   <tt>pattern</tt>.
splitKeepEnd :: ByteString -> ByteString -> [ByteString]

-- | <tt><a>splitKeepFront</a></tt> is like <a>splitKeepEnd</a>, except
--   that <tt>target</tt> is split before each occurrence of
--   <tt>pattern</tt> and hence all fragments with the possible exception
--   of the first begin with <tt>pattern</tt>. No fragment contains more
--   than one non-overlapping occurrence of <tt>pattern</tt>.
splitKeepFront :: ByteString -> ByteString -> [ByteString]


-- | Fast overlapping Boyer-Moore search of both strict and lazy
--   <tt>ByteString</tt> values.
--   
--   Descriptions of the algorithm can be found at
--   <a>http://www-igm.univ-mlv.fr/~lecroq/string/node14.html#SECTION00140</a>
--   and
--   <a>http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm</a>
--   
--   Original authors: Daniel Fischer (daniel.is.fischer at googlemail.com)
--   and Chris Kuklewicz (haskell at list.mightyreason.com).

-- | <i>Deprecated: Use the new interface instead </i>
module Data.ByteString.Search.BoyerMoore

-- | <tt><a>matchLL</a></tt> finds the starting indices of all possibly
--   overlapping occurrences of the pattern in the target string. It is a
--   simple wrapper for <a>indices</a>. If the pattern is empty, the result
--   is <tt>[0 .. <a>length</a> target]</tt>.
matchLL :: ByteString -> ByteString -> [Int64]

-- | <tt><a>matchLS</a></tt> finds the starting indices of all possibly
--   overlapping occurrences of the pattern in the target string. It is a
--   simple wrapper for <a>indices</a>. If the pattern is empty, the result
--   is <tt>[0 .. <a>length</a> target]</tt>.
matchLS :: ByteString -> ByteString -> [Int]

-- | <tt><a>matchSL</a></tt> finds the starting indices of all possibly
--   overlapping occurrences of the pattern in the target string. It is an
--   alias for <a>indices</a>. If the pattern is empty, the result is
--   <tt>[0 .. <a>length</a> target]</tt>.
matchSL :: ByteString -> ByteString -> [Int64]

-- | <tt><a>matchSS</a></tt> finds the starting indices of all possibly
--   overlapping occurrences of the pattern in the target string. It is an
--   alias for <a>indices</a>. If the pattern is empty, the result is
--   <tt>[0 .. <a>length</a> target]</tt>.
matchSS :: ByteString -> ByteString -> [Int]


-- | Fast overlapping Boyer-Moore search of strict <a>ByteString</a>
--   values. Breaking, splitting and replacing using the Boyer-Moore
--   algorithm.
--   
--   Descriptions of the algorithm can be found at
--   <a>http://www-igm.univ-mlv.fr/~lecroq/string/node14.html#SECTION00140</a>
--   and
--   <a>http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm</a>
--   
--   Original authors: Daniel Fischer (daniel.is.fischer at googlemail.com)
--   and Chris Kuklewicz (haskell at list.mightyreason.com).
module Data.ByteString.Search

-- | <tt><a>indices</a></tt> finds the starting indices of all possibly
--   overlapping occurrences of the pattern in the target string. If the
--   pattern is empty, the result is <tt>[0 .. <a>length</a> target]</tt>.
--   
--   In general, <tt><a>not</a> . <a>null</a> $ <a>indices</a> pat
--   target</tt> is a much more efficient version of <a>isInfixOf</a>.
indices :: ByteString -> ByteString -> [Int]

-- | <tt><a>nonOverlappingIndices</a></tt> finds the starting indices of
--   all non-overlapping occurrences of the pattern in the target string.
--   It is more efficient than removing indices from the list produced by
--   <a>indices</a>.
nonOverlappingIndices :: ByteString -> ByteString -> [Int]

-- | <tt><a>breakOn</a> pattern target</tt> splits <tt>target</tt> at the
--   first occurrence of <tt>pattern</tt>. If the pattern does not occur in
--   the target, the second component of the result is empty, otherwise it
--   starts with <tt>pattern</tt>. If the pattern is empty, the first
--   component is empty.
--   
--   <pre>
--   <a>uncurry</a> <a>append</a> . <a>breakOn</a> pattern = <a>id</a>
--   </pre>
breakOn :: ByteString -> ByteString -> (ByteString, ByteString)

-- | <tt><a>breakAfter</a> pattern target</tt> splits <tt>target</tt>
--   behind the first occurrence of <tt>pattern</tt>. An empty second
--   component means that either the pattern does not occur in the target
--   or the first occurrence of pattern is at the very end of target. To
--   discriminate between those cases, use e.g. <a>isSuffixOf</a>.
--   
--   <pre>
--   <a>uncurry</a> <a>append</a> . <a>breakAfter</a> pattern = <a>id</a>
--   </pre>
breakAfter :: ByteString -> ByteString -> (ByteString, ByteString)

-- | <tt><a>replace</a> pat sub text</tt> replaces all (non-overlapping)
--   occurrences of <tt>pat</tt> in <tt>text</tt> with <tt>sub</tt>. If
--   occurrences of <tt>pat</tt> overlap, the first occurrence that does
--   not overlap with a replaced previous occurrence is substituted.
--   Occurrences of <tt>pat</tt> arising from a substitution will not be
--   substituted. For example:
--   
--   <pre>
--   <a>replace</a> "ana" "olog" "banana" = "bologna"
--   <a>replace</a> "ana" "o" "bananana" = "bono"
--   <a>replace</a> "aab" "abaa" "aaabb" = "aabaab"
--   </pre>
--   
--   The result is a <i>lazy</i> <a>ByteString</a>, which is lazily
--   produced, without copying. Equality of pattern and substitution is not
--   checked, but
--   
--   <pre>
--   (<a>concat</a> . <a>toChunks</a> $ <a>replace</a> pat pat text) == text
--   </pre>
--   
--   holds. If the pattern is empty but not the substitution, the result is
--   equivalent to (were they <a>String</a>s) <tt><a>cycle</a> sub</tt>.
--   
--   For non-empty <tt>pat</tt> and <tt>sub</tt> a strict
--   <a>ByteString</a>,
--   
--   <pre>
--   <a>fromChunks</a> . <a>intersperse</a> sub . <a>split</a> pat = <a>replace</a> pat sub
--   </pre>
--   
--   and analogous relations hold for other types of <tt>sub</tt>.
replace :: Substitution rep => ByteString -> rep -> ByteString -> ByteString

-- | <tt><a>split</a> pattern target</tt> splits <tt>target</tt> at each
--   (non-overlapping) occurrence of <tt>pattern</tt>, removing
--   <tt>pattern</tt>. If <tt>pattern</tt> is empty, the result is an
--   infinite list of empty <a>ByteString</a>s, if <tt>target</tt> is empty
--   but not <tt>pattern</tt>, the result is an empty list, otherwise the
--   following relations hold:
--   
--   <pre>
--   <a>concat</a> . <a>intersperse</a> pat . <a>split</a> pat = <a>id</a>,
--   <a>length</a> (<a>split</a> pattern target) ==
--               <a>length</a> (<a>nonOverlappingIndices</a> pattern target) + 1,
--   </pre>
--   
--   no fragment in the result contains an occurrence of <tt>pattern</tt>.
split :: ByteString -> ByteString -> [ByteString]

-- | <tt><a>splitKeepEnd</a> pattern target</tt> splits <tt>target</tt>
--   after each (non-overlapping) occurrence of <tt>pattern</tt>. If
--   <tt>pattern</tt> is empty, the result is an infinite list of empty
--   <a>ByteString</a>s, otherwise the following relations hold:
--   
--   <pre>
--   <a>concat</a> . <a>splitKeepEnd</a> pattern = <a>id</a>,
--   </pre>
--   
--   all fragments in the result except possibly the last end with
--   <tt>pattern</tt>, no fragment contains more than one occurrence of
--   <tt>pattern</tt>.
splitKeepEnd :: ByteString -> ByteString -> [ByteString]

-- | <tt><a>splitKeepFront</a></tt> is like <a>splitKeepEnd</a>, except
--   that <tt>target</tt> is split before each occurrence of
--   <tt>pattern</tt> and hence all fragments with the possible exception
--   of the first begin with <tt>pattern</tt>. No fragment contains more
--   than one non-overlapping occurrence of <tt>pattern</tt>.
splitKeepFront :: ByteString -> ByteString -> [ByteString]