-- 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 ByteString -- using the Karp-Rabin algorithm. -- -- A description of the algorithm for a single pattern can be found at -- http://www-igm.univ-mlv.fr/~lecroq/string/node5.html#SECTION0050. module Data.ByteString.Lazy.Search.KarpRabin -- | indicesOfAny 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 -- ByteString using the Karp-Rabin algorithm. -- -- A description of the algorithm for a single pattern can be found at -- http://www-igm.univ-mlv.fr/~lecroq/string/node5.html#SECTION0050. module Data.ByteString.Search.KarpRabin -- | indicesOfAny 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 ByteString values using the -- Knuth-Morris-Pratt algorithm. -- -- A description of the algorithm can be found at -- http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm. -- -- Original authors: Justin Bailey (jgbailey at gmail.com) and Chris -- Kuklewicz (haskell at list.mightyreason.com). module Data.ByteString.Search.KMP -- | indices finds the starting indices of all possibly -- overlapping occurrences of the pattern in the target string. If the -- pattern is empty, the result is [0 .. length target]. indices :: ByteString -> ByteString -> [Int] -- | nonOverlappingIndices 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 -- indices. nonOverlappingIndices :: ByteString -> ByteString -> [Int] -- | Fast non-overlapping Knuth-Morris-Pratt search of both strict and lazy -- ByteString values. -- -- A description of the algorithm can be found at -- http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm. -- -- Original authors: Justin Bailey (jgbailey at gmail.com) and Chris -- Kuklewicz (haskell at list.mightyreason.com). -- | Deprecated: Use the new interface instead module Data.ByteString.Search.KnuthMorrisPratt -- | matchLL finds the starting indices of all -- non-overlapping occurrences of the pattern in the target -- string. It is a simple wrapper around nonOverlappingIndices -- strictifying the pattern. matchLL :: ByteString -> ByteString -> [Int64] -- | matchLS finds the starting indices of all -- non-overlapping occurrences of the pattern in the target -- string. It is a simple wrapper around nonOverlappingIndices -- strictifying the pattern. matchLS :: ByteString -> ByteString -> [Int] -- | matchSS finds the starting indices of all -- non-overlapping occurrences of the pattern in the target -- string. It is an alias for nonOverlappingIndices. matchSS :: ByteString -> ByteString -> [Int] -- | matchSL finds the starting indices of all -- non-overlapping occurrences of the pattern in the target -- string. It is an alias for nonOverlappingIndices. matchSL :: ByteString -> ByteString -> [Int64] -- | Fast search of lazy ByteString values using the -- Knuth-Morris-Pratt algorithm. -- -- A description of the algorithm can be found at -- http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm. -- -- Original authors: Justin Bailey (jgbailey at gmail.com) and Chris -- Kuklewicz (haskell at list.mightyreason.com). module Data.ByteString.Lazy.Search.KMP -- | indices finds the starting indices of all possibly -- overlapping occurrences of the pattern in the target string. If the -- pattern is empty, the result is [0 .. length target]. indices :: ByteString -> ByteString -> [Int64] -- | nonOverlappingIndices 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 -- indices. nonOverlappingIndices :: ByteString -> ByteString -> [Int64] -- | strictify transforms a lazy ByteString into a -- strict ByteString, to make it a suitable pattern for the -- searching functions. strictify :: ByteString -> ByteString -- | Class for values to be substituted into strict and lazy -- ByteStrings by the replace 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 ByteString values. Breaking, splitting -- and replacing using a deterministic finite automaton. module Data.ByteString.Search.DFA -- | indices finds the starting indices of all possibly -- overlapping occurrences of the pattern in the target string. If the -- pattern is empty, the result is [0 .. length target]. indices :: ByteString -> ByteString -> [Int] -- | nonOverlappingIndices 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 -- indices. nonOverlappingIndices :: ByteString -> ByteString -> [Int] -- | breakOn pattern target splits target at the -- first occurrence of pattern. If the pattern does not occur in -- the target, the second component of the result is empty, otherwise it -- starts with pattern. If the pattern is empty, the first -- component is empty. -- --
--   uncurry append . breakOn pattern = id
--   
breakOn :: ByteString -> ByteString -> (ByteString, ByteString) -- | breakAfter pattern target splits target -- behind the first occurrence of pattern. 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. isSuffixOf. -- --
--   uncurry append . breakAfter pattern = id
--   
breakAfter :: ByteString -> ByteString -> (ByteString, ByteString) -- | replace pat sub text replaces all (non-overlapping) -- occurrences of pat in text with sub. If -- occurrences of pat overlap, the first occurrence that does -- not overlap with a replaced previous occurrence is substituted. -- Occurrences of pat arising from a substitution will not be -- substituted. For example: -- --
--   replace "ana" "olog" "banana" = "bologna"
--   replace "ana" "o" "bananana" = "bono"
--   replace "aab" "abaa" "aaabb" = "aabaab"
--   
-- -- The result is a lazy ByteString, which is lazily -- produced, without copying. Equality of pattern and substitution is not -- checked, but -- --
--   concat . toChunks $ replace pat pat text == text
--   
-- -- holds. If the pattern is empty but not the substitution, the result is -- equivalent to (were they Strings) cycle sub. -- -- For non-empty pat and sub a strict -- ByteString, -- --
--   fromChunks . intersperse sub . split pat = replace pat sub
--   
-- -- and analogous relations hold for other types of sub. replace :: Substitution rep => ByteString -> rep -> ByteString -> ByteString -- | split pattern target splits target at each -- (non-overlapping) occurrence of pattern, removing -- pattern. If pattern is empty, the result is an -- infinite list of empty ByteStrings, if target is empty -- but not pattern, the result is an empty list, otherwise the -- following relations hold: -- --
--   concat . intersperse pat . split pat = id,
--   length (split pattern target) ==
--               length (nonOverlappingIndices pattern target) + 1,
--   
-- -- no fragment in the result contains an occurrence of pattern. split :: ByteString -> ByteString -> [ByteString] -- | splitKeepEnd pattern target splits target -- after each (non-overlapping) occurrence of pattern. If -- pattern is empty, the result is an infinite list of empty -- ByteStrings, otherwise the following relations hold: -- --
--   concat . splitKeepEnd pattern = id,
--   
-- -- all fragments in the result except possibly the last end with -- pattern, no fragment contains more than one occurrence of -- pattern. splitKeepEnd :: ByteString -> ByteString -> [ByteString] -- | splitKeepFront is like splitKeepEnd, except -- that target is split before each occurrence of -- pattern and hence all fragments with the possible exception -- of the first begin with pattern. No fragment contains more -- than one non-overlapping occurrence of pattern. splitKeepFront :: ByteString -> ByteString -> [ByteString] -- | Fast overlapping Boyer-Moore search of lazy ByteString values. -- Breaking, splitting and replacing using the Boyer-Moore algorithm. -- -- Descriptions of the algorithm can be found at -- http://www-igm.univ-mlv.fr/~lecroq/string/node14.html#SECTION00140 -- and -- http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm -- -- Original authors: Daniel Fischer (daniel.is.fischer at googlemail.com) -- and Chris Kuklewicz (haskell at list.mightyreason.com). module Data.ByteString.Lazy.Search -- | indices finds the starting indices of all possibly -- overlapping occurrences of the pattern in the target string. If the -- pattern is empty, the result is [0 .. length target]. indices :: ByteString -> ByteString -> [Int64] -- | nonOverlappingIndices 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 -- indices. nonOverlappingIndices :: ByteString -> ByteString -> [Int64] -- | breakOn pattern target splits target at the -- first occurrence of pattern. If the pattern does not occur in -- the target, the second component of the result is empty, otherwise it -- starts with pattern. 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. -- --
--   uncurry append . breakOn pattern = id
--   
breakOn :: ByteString -> ByteString -> (ByteString, ByteString) -- | breakAfter pattern target splits target -- behind the first occurrence of pattern. 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. -- --
--   uncurry append . breakAfter pattern = id
--   
breakAfter :: ByteString -> ByteString -> (ByteString, ByteString) -- | breakFindAfter does the same as breakAfter but -- additionally indicates whether the pattern is present in the target. -- --
--   fst . breakFindAfter pat = breakAfter pat
--   
breakFindAfter :: ByteString -> ByteString -> ((ByteString, ByteString), Bool) -- | replace pat sub text replaces all (non-overlapping) -- occurrences of pat in text with sub. If -- occurrences of pat overlap, the first occurrence that does -- not overlap with a replaced previous occurrence is substituted. -- Occurrences of pat arising from a substitution will not be -- substituted. For example: -- --
--   replace "ana" "olog" "banana" = "bologna"
--   replace "ana" "o" "bananana" = "bono"
--   replace "aab" "abaa" "aaabb" = "aabaab"
--   
-- -- The result is a lazy ByteString, which is lazily produced, -- without copying. Equality of pattern and substitution is not checked, -- but -- --
--   replace pat pat text == text
--   
-- -- holds (the internal structure is generally different). If the pattern -- is empty but not the substitution, the result is equivalent to (were -- they Strings) cycle sub. -- -- For non-empty pat and sub a lazy ByteString, -- --
--   concat . intersperse sub . split pat = replace pat sub
--   
-- -- and analogous relations hold for other types of sub. replace :: Substitution rep => ByteString -> rep -> ByteString -> ByteString -- | split pattern target splits target at each -- (non-overlapping) occurrence of pattern, removing -- pattern. If pattern is empty, the result is an -- infinite list of empty ByteStrings, if target is empty -- but not pattern, the result is an empty list, otherwise the -- following relations hold (where patL is the lazy -- ByteString corresponding to pat): -- --
--   concat . intersperse patL . split pat = id,
--   length (split pattern target) ==
--               length (nonOverlappingIndices pattern target) + 1,
--   
-- -- no fragment in the result contains an occurrence of pattern. split :: ByteString -> ByteString -> [ByteString] -- | splitKeepEnd pattern target splits target -- after each (non-overlapping) occurrence of pattern. If -- pattern is empty, the result is an infinite list of empty -- ByteStrings, otherwise the following relations hold: -- --
--   concat . splitKeepEnd pattern = id,
--   
-- -- all fragments in the result except possibly the last end with -- pattern, no fragment contains more than one occurrence of -- pattern. splitKeepEnd :: ByteString -> ByteString -> [ByteString] -- | splitKeepFront is like splitKeepEnd, except -- that target is split before each occurrence of -- pattern and hence all fragments with the possible exception -- of the first begin with pattern. No fragment contains more -- than one non-overlapping occurrence of pattern. splitKeepFront :: ByteString -> ByteString -> [ByteString] -- | strictify converts a lazy ByteString to a -- strict ByteString to make it a suitable pattern. strictify :: ByteString -> ByteString -- | Fast search of lazy ByteString values. Breaking, splitting and -- replacing using a deterministic finite automaton. module Data.ByteString.Lazy.Search.DFA -- | indices finds the starting indices of all possibly -- overlapping occurrences of the pattern in the target string. If the -- pattern is empty, the result is [0 .. length target]. indices :: ByteString -> ByteString -> [Int64] -- | nonOverlappingIndices 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 -- indices. nonOverlappingIndices :: ByteString -> ByteString -> [Int64] -- | breakOn pattern target splits target at the -- first occurrence of pattern. If the pattern does not occur in -- the target, the second component of the result is empty, otherwise it -- starts with pattern. 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. -- --
--   uncurry append . breakOn pattern = id
--   
breakOn :: ByteString -> ByteString -> (ByteString, ByteString) -- | breakAfter pattern target splits target -- behind the first occurrence of pattern. 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. uncurry append . breakAfter -- pattern = id breakAfter :: ByteString -> ByteString -> (ByteString, ByteString) -- | breakFindAfter does the same as breakAfter but -- additionally indicates whether the pattern is present in the target. -- --
--   fst . breakFindAfter pat = breakAfter pat
--   
breakFindAfter :: ByteString -> ByteString -> ((ByteString, ByteString), Bool) -- | replace pat sub text replaces all (non-overlapping) -- occurrences of pat in text with sub. If -- occurrences of pat overlap, the first occurrence that does -- not overlap with a replaced previous occurrence is substituted. -- Occurrences of pat arising from a substitution will not be -- substituted. For example: -- --
--   replace "ana" "olog" "banana" = "bologna"
--   replace "ana" "o" "bananana" = "bono"
--   replace "aab" "abaa" "aaabb" = "aabaab"
--   
-- -- The result is a lazy ByteString, which is lazily produced, -- without copying. Equality of pattern and substitution is not checked, -- but -- --
--   replace pat pat text == text
--   
-- -- holds (the internal structure is generally different). If the pattern -- is empty but not the substitution, the result is equivalent to (were -- they Strings) cycle sub. -- -- For non-empty pat and sub a lazy ByteString, -- --
--   concat . intersperse sub . split pat = replace pat sub
--   
-- -- and analogous relations hold for other types of sub. replace :: Substitution rep => ByteString -> rep -> ByteString -> ByteString -- | split pattern target splits target at each -- (non-overlapping) occurrence of pattern, removing -- pattern. If pattern is empty, the result is an -- infinite list of empty ByteStrings, if target is empty -- but not pattern, the result is an empty list, otherwise the -- following relations hold (where patL is the lazy -- ByteString corresponding to pat): -- --
--   concat . intersperse patL . split pat = id,
--   length (split pattern target) ==
--               length (nonOverlappingIndices pattern target) + 1,
--   
-- -- no fragment in the result contains an occurrence of pattern. split :: ByteString -> ByteString -> [ByteString] -- | splitKeepEnd pattern target splits target -- after each (non-overlapping) occurrence of pattern. If -- pattern is empty, the result is an infinite list of empty -- ByteStrings, otherwise the following relations hold: -- --
--   concat . splitKeepEnd pattern = 'id,'
--   
-- -- all fragments in the result except possibly the last end with -- pattern, no fragment contains more than one occurrence of -- pattern. splitKeepEnd :: ByteString -> ByteString -> [ByteString] -- | splitKeepFront is like splitKeepEnd, except -- that target is split before each occurrence of -- pattern and hence all fragments with the possible exception -- of the first begin with pattern. No fragment contains more -- than one non-overlapping occurrence of pattern. splitKeepFront :: ByteString -> ByteString -> [ByteString] -- | Fast overlapping Boyer-Moore search of both strict and lazy -- ByteString values. -- -- Descriptions of the algorithm can be found at -- http://www-igm.univ-mlv.fr/~lecroq/string/node14.html#SECTION00140 -- and -- http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm -- -- Original authors: Daniel Fischer (daniel.is.fischer at googlemail.com) -- and Chris Kuklewicz (haskell at list.mightyreason.com). -- | Deprecated: Use the new interface instead module Data.ByteString.Search.BoyerMoore -- | matchLL finds the starting indices of all possibly -- overlapping occurrences of the pattern in the target string. It is a -- simple wrapper for indices. If the pattern is empty, the result -- is [0 .. length target]. matchLL :: ByteString -> ByteString -> [Int64] -- | matchLS finds the starting indices of all possibly -- overlapping occurrences of the pattern in the target string. It is a -- simple wrapper for indices. If the pattern is empty, the result -- is [0 .. length target]. matchLS :: ByteString -> ByteString -> [Int] -- | matchSL finds the starting indices of all possibly -- overlapping occurrences of the pattern in the target string. It is an -- alias for indices. If the pattern is empty, the result is -- [0 .. length target]. matchSL :: ByteString -> ByteString -> [Int64] -- | matchSS finds the starting indices of all possibly -- overlapping occurrences of the pattern in the target string. It is an -- alias for indices. If the pattern is empty, the result is -- [0 .. length target]. matchSS :: ByteString -> ByteString -> [Int] -- | Fast overlapping Boyer-Moore search of strict ByteString -- values. Breaking, splitting and replacing using the Boyer-Moore -- algorithm. -- -- Descriptions of the algorithm can be found at -- http://www-igm.univ-mlv.fr/~lecroq/string/node14.html#SECTION00140 -- and -- http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm -- -- Original authors: Daniel Fischer (daniel.is.fischer at googlemail.com) -- and Chris Kuklewicz (haskell at list.mightyreason.com). module Data.ByteString.Search -- | indices finds the starting indices of all possibly -- overlapping occurrences of the pattern in the target string. If the -- pattern is empty, the result is [0 .. length target]. -- -- In general, not . null $ indices pat -- target is a much more efficient version of isInfixOf. indices :: ByteString -> ByteString -> [Int] -- | nonOverlappingIndices 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 -- indices. nonOverlappingIndices :: ByteString -> ByteString -> [Int] -- | breakOn pattern target splits target at the -- first occurrence of pattern. If the pattern does not occur in -- the target, the second component of the result is empty, otherwise it -- starts with pattern. If the pattern is empty, the first -- component is empty. -- --
--   uncurry append . breakOn pattern = id
--   
breakOn :: ByteString -> ByteString -> (ByteString, ByteString) -- | breakAfter pattern target splits target -- behind the first occurrence of pattern. 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. isSuffixOf. -- --
--   uncurry append . breakAfter pattern = id
--   
breakAfter :: ByteString -> ByteString -> (ByteString, ByteString) -- | replace pat sub text replaces all (non-overlapping) -- occurrences of pat in text with sub. If -- occurrences of pat overlap, the first occurrence that does -- not overlap with a replaced previous occurrence is substituted. -- Occurrences of pat arising from a substitution will not be -- substituted. For example: -- --
--   replace "ana" "olog" "banana" = "bologna"
--   replace "ana" "o" "bananana" = "bono"
--   replace "aab" "abaa" "aaabb" = "aabaab"
--   
-- -- The result is a lazy ByteString, which is lazily -- produced, without copying. Equality of pattern and substitution is not -- checked, but -- --
--   (concat . toChunks $ replace pat pat text) == text
--   
-- -- holds. If the pattern is empty but not the substitution, the result is -- equivalent to (were they Strings) cycle sub. -- -- For non-empty pat and sub a strict -- ByteString, -- --
--   fromChunks . intersperse sub . split pat = replace pat sub
--   
-- -- and analogous relations hold for other types of sub. replace :: Substitution rep => ByteString -> rep -> ByteString -> ByteString -- | split pattern target splits target at each -- (non-overlapping) occurrence of pattern, removing -- pattern. If pattern is empty, the result is an -- infinite list of empty ByteStrings, if target is empty -- but not pattern, the result is an empty list, otherwise the -- following relations hold: -- --
--   concat . intersperse pat . split pat = id,
--   length (split pattern target) ==
--               length (nonOverlappingIndices pattern target) + 1,
--   
-- -- no fragment in the result contains an occurrence of pattern. split :: ByteString -> ByteString -> [ByteString] -- | splitKeepEnd pattern target splits target -- after each (non-overlapping) occurrence of pattern. If -- pattern is empty, the result is an infinite list of empty -- ByteStrings, otherwise the following relations hold: -- --
--   concat . splitKeepEnd pattern = id,
--   
-- -- all fragments in the result except possibly the last end with -- pattern, no fragment contains more than one occurrence of -- pattern. splitKeepEnd :: ByteString -> ByteString -> [ByteString] -- | splitKeepFront is like splitKeepEnd, except -- that target is split before each occurrence of -- pattern and hence all fragments with the possible exception -- of the first begin with pattern. No fragment contains more -- than one non-overlapping occurrence of pattern. splitKeepFront :: ByteString -> ByteString -> [ByteString]