úÎ!ôòs     ©2019 James BrockBSD2"James Brock <jamesbrock@gmail.com>None_„Y replace-attoparsec Break on and capture one pattern‰Find the first occurence of a pattern in a text stream, capture the found pattern, and break the input text stream on the found pattern.The  function is like R, but can be predicated beyond more than just the next one token. It's also like  , but the needle/ can be a pattern instead of a constant string..Be careful not to look too far ahead; if the sep+ parser looks to the end of the input then  could be O(n²).The pattern parser sepW may match a zero-width pattern (a pattern which consumes no parser input on success).OutputNothing! when no pattern match was found.#Just (prefix, parse_result, suffix): for the result of parsing the pattern match, and the prefix string before and the suffix% string after the pattern match. prefix and suffix may be zero-length strings."Access the matched section of textLIf you want to capture the matched string, then combine the pattern parser sep with .FWith the matched string, we can reconstruct in input string. For all input, sep, if let (+ (prefix, (infix, _), suffix)) = breakCap ( sep) input then input == prefix  infix  suffix replace-attoparsec!Split on and capture all patterns#Find all occurences of the pattern sepC, split the input string, capture all the patterns and the splits.[The input string will be split on every leftmost non-overlapping occurence of the pattern sep[. The output list will contain the parsed result of input string sections which match the sep pattern in , and non-matching sections in . depends on , see  for more details."Access the matched section of textMIf you want to capture the matched strings, then combine the pattern parser sep with .GWith the matched strings, we can reconstruct in input string. For all input, sep, if let output = splitCap ( sep) input then  input ==   (    output) replace-attoparsec Stream editor~Also known as find-and-replace , or match-and-substitute . Finds all of the sections of the stream which match the pattern sep,, and replaces them with the result of the editor function.*Access the matched section of text in the editor0If you want access to the matched string in the editor, function, then combine the pattern parser sep with 0. This will effectively change the type of the editor function to (ByteString,a) -> ByteString.This allows us to write an editorU function which can choose to not edit the match and just leave it as it is. If the editor5 function returns the first item in the tuple, then  streamEdit% will not change the matched string. So, for all sep:  streamEdit ( sep)   "a   replace-attoparsecStream editor transformerMonad transformer version of .The editor3 function will run in the underlying monad context.If you want to do  operations in the editor function then run this in .If you want the editorE function to remember some state, then run this in a stateful monad.replace-attoparsec Specialized ehttp://hackage.haskell.org/package/parser-combinators/docs/Control-Monad-Combinators.html#v:manyTill_ manyTill_9Parser combinator to consume and capture input until the sep" pattern matches, equivalent to   sepP. On success, returns the prefix before the pattern match and the parsed match.sepI may be a zero-width parser, it may succeed without consuming any input.7This combinator will produce a parser which acts like O but is predicated beyond more than just the next one token. It is also like , in that it is a high performance  parser.replace-attoparsecSeparate and capturePParser combinator to find all of the non-overlapping ocurrences of the pattern sep in a text stream. The @ parser will always consume its entire input and can never fail.sepCap is similar to the sep* family of functions found in  Yhttp://hackage.haskell.org/package/parser-combinators/docs/Control-Monad-Combinators.htmlparser-combinators and  Lhttp://hackage.haskell.org/package/parsers/docs/Text-Parser-Combinators.htmlparsers+, but it returns the parsed result of the sep% parser instead of throwing it away.OutputAThe input stream is separated and output into a list of sections:)Sections which can parsed by the pattern sep# will be parsed and captured as 8Non-matching sections of the stream will be captured in .*The output list also has these properties:If the input is "" then the output list will be [].fIf there are no pattern matches, then the entire input stream will be returned as one non-matching  section.1The output list will not contain two consecutive  sections.Zero-width matches forbiddenIf the pattern matching parser sep1 would succeed without consuming any input then % will force it to fail. If we allow sepË to match a zero-width pattern, then it can match the same zero-width pattern again at the same position on the next iteration, which would result in an infinite number of overlapping pattern matches.replace-attoparsec6Find all occurences, parse and capture pattern matchesFParser combinator for finding all occurences of a pattern in a stream. Will call  with the ? combinator so that the text which matched the pattern parser sep will be returned in the 1 sections, along with the result of the parse of sep. Definition: findAllCap sep =  ( sep) replace-attoparsecFind all occurencesFParser combinator for finding all occurences of a pattern in a stream. Will call  with the B combinator and return the text which matched the pattern parser sep in the  sections. Definition: findAll sep = (fmap.fmap) ( fst) $  ( sep) replace-attoparsecGet the  current offset  in the stream. ,https://github.com/bos/attoparsec/issues/101>  & you know you're in an uncomfortable state of sin :-)   bosreplace-attoparsec'Using this advance function instead of ? seems to give us a 5%-20% performance improvement for sepCap.It's safe to use  because after  we always check for 0 before trying to read anything from the buffer. qhttp://hackage.haskell.org/package/attoparsec-0.13.2.3/docs/src/Data.Attoparsec.ByteString.Internal.html#anyWord8 phttp://hackage.haskell.org/package/attoparsec-0.13.2.3/docs/src/Data.Attoparsec.ByteString.Internal.html#advancereplace-attoparsec_Extract a substring from part of the buffer that we've already visited. Does not check bounds.4The idea here is that we go back and run the parser Œ at the Pos which we saved from before, and then we continue from the current Pos, hopefully without messing up the internal parser state.^Should be equivalent to the unexported function Data.Attoparsec.ByteString.Buffer.substring phttp://hackage.haskell.org/package/attoparsec-0.13.2.3/docs/src/Data.Attoparsec.ByteString.Buffer.html#substringàThis is a performance optimization for gathering the unmatched sections of the input. The alternative is to accumulate unmatched characters one anyWord8 at a time in a list of [Word8] and then pack them into a ByteString.replace-attoparsecThe pattern matching parser sepreplace-attoparsecThe input stream of textreplace-attoparsec$Maybe (prefix, parse_result, suffix)replace-attoparsecThe pattern matching parser sepreplace-attoparsecThe input stream of textreplace-attoparsec0List of matching and non-matching input sectionsreplace-attoparsecThe pattern matching parser sepreplace-attoparsecThe editor$ function. Takes a parsed result of sep7 and returns a new stream section for the replacement.replace-attoparsec%The input stream of text to be editedreplace-attoparsecThe edited input streamreplace-attoparsecThe pattern matching parser sepreplace-attoparsecThe editor$ function. Takes a parsed result of sep7 and returns a new stream section for the replacement.replace-attoparsec%The input stream of text to be editedreplace-attoparsecThe edited input streamreplace-attoparsecThe pattern matching parser sepreplace-attoparsecparserreplace-attoparsecThe pattern matching parser sepreplace-attoparsecparserreplace-attoparsecThe pattern matching parser sepreplace-attoparsecparserreplace-attoparsecThe pattern matching parser sepreplace-attoparsecparser©2019 James BrockBSD2"James Brock <jamesbrock@gmail.com>None_ò/replace-attoparsec Break on and capture one pattern‰Find the first occurence of a pattern in a text stream, capture the found pattern, and break the input text stream on the found pattern.The  function is like R, but can be predicated beyond more than just the next one token. It's also like  , but the needle/ can be a pattern instead of a constant string..Be careful not to look too far ahead; if the sep+ parser looks to the end of the input then  could be O(n²).The pattern parser sepW may match a zero-width pattern (a pattern which consumes no parser input on success).OutputNothing! when no pattern match was found.#Just (prefix, parse_result, suffix): for the result of parsing the pattern match, and the prefix string before and the suffix% string after the pattern match. prefix and suffix may be zero-length strings."Access the matched section of textLIf you want to capture the matched string, then combine the pattern parser sep with .FWith the matched string, we can reconstruct in input string. For all input, sep, if let (+ (prefix, (infix, _), suffix)) = breakCap ( sep) input then input == prefix  infix  suffix replace-attoparsec!Split on and capture all patterns#Find all occurences of the pattern sepC, split the input string, capture all the patterns and the splits.[The input string will be split on every leftmost non-overlapping occurence of the pattern sep[. The output list will contain the parsed result of input string sections which match the sep pattern in , and non-matching sections in .  depends on  , see   for more details."Access the matched section of textMIf you want to capture the matched strings, then combine the pattern parser sep with .GWith the matched strings, we can reconstruct in input string. For all input, sep, if let output = splitCap ( sep) input then  input ==   (    output) replace-attoparsec Stream editor~Also known as find-and-replace , or match-and-substitute . Finds all of the sections of the stream which match the pattern sep,, and replaces them with the result of the editor function.*Access the matched section of text in the editor0If you want access to the matched string in the editor, function, then combine the pattern parser sep with 0. This will effectively change the type of the editor function to (Text,a) -> Text.This allows us to write an editorU function which can choose to not edit the match and just leave it as it is. If the editor5 function returns the first item in the tuple, then  streamEdit% will not change the matched string. So, for all sep:  streamEdit ( sep)   "a   replace-attoparsecStream editor transformerMonad transformer version of  .The editor3 function will run in the underlying monad context.If you want to do  operations in the editor function then run this in .If you want the editorE function to remember some state, then run this in a stateful monad. replace-attoparsec Specialized ehttp://hackage.haskell.org/package/parser-combinators/docs/Control-Monad-Combinators.html#v:manyTill_ manyTill_9Parser combinator to consume and capture input until the sep" pattern matches, equivalent to   sepP. On success, returns the prefix before the pattern match and the parsed match.sepI may be a zero-width parser, it may succeed without consuming any input.7This combinator will produce a parser which acts like O but is predicated beyond more than just the next one token. It is also like + in that it is a high performance  parser. replace-attoparsecSeparate and capturePParser combinator to find all of the non-overlapping ocurrences of the pattern sep in a text stream. The  @ parser will always consume its entire input and can never fail.  is similar to the sep* family of functions found in  Yhttp://hackage.haskell.org/package/parser-combinators/docs/Control-Monad-Combinators.htmlparser-combinators and  Lhttp://hackage.haskell.org/package/parsers/docs/Text-Parser-Combinators.htmlparsers+, but it returns the parsed result of the sep% parser instead of throwing it away.OutputAThe input stream is separated and output into a list of sections:)Sections which can parsed by the pattern sep# will be parsed and captured as 8Non-matching sections of the stream will be captured in .*The output list also has these properties:If the input is "" then the output list will be [].fIf there are no pattern matches, then the entire input stream will be returned as one non-matching  section.1The output list will not contain two consecutive  sections.Zero-width matches forbiddenIf the pattern matching parser sep1 would succeed without consuming any input then  % will force it to fail. If we allow sepË to match a zero-width pattern, then it can match the same zero-width pattern again at the same position on the next iteration, which would result in an infinite number of overlapping pattern matches.replace-attoparsec6Find all occurences, parse and capture pattern matchesFParser combinator for finding all occurences of a pattern in a stream. Will call   with the ? combinator so that the text which matched the pattern parser sep will be returned in the 1 sections, along with the result of the parse of sep. Definition: findAllCap sep =   ( sep) replace-attoparsecFind all occurencesFParser combinator for finding all occurences of a pattern in a stream. Will call   with the B combinator and return the text which matched the pattern parser sep in the  sections. Definition: findAll sep = (fmap.fmap) ( fst) $   ( sep) replace-attoparsecThe pattern matching parser sepreplace-attoparsecThe input stream of textreplace-attoparsec$Maybe (prefix, parse_result, suffix) replace-attoparsecThe pattern matching parser sepreplace-attoparsecThe input stream of textreplace-attoparsec0List of matching and non-matching input sections replace-attoparsecThe pattern matching parser sepreplace-attoparsecThe editor$ function. Takes a parsed result of sep7 and returns a new stream section for the replacement.replace-attoparsec%The input stream of text to be editedreplace-attoparsecThe edited input stream replace-attoparsecThe pattern matching parser sepreplace-attoparsecThe editor$ function. Takes a parsed result of sep7 and returns a new stream section for the replacement.replace-attoparsec%The input stream of text to be editedreplace-attoparsecThe edited input stream replace-attoparsecThe pattern matching parser sepreplace-attoparsecparser replace-attoparsecThe pattern matching parser sepreplace-attoparsecparserreplace-attoparsecThe pattern matching parser sepreplace-attoparsecparserreplace-attoparsecThe pattern matching parser sepreplace-attoparsecparser   !" #$ %& %' () *+,-./0121345 6781replace-attoparsec-1.4.0.0-J2RGI5caxHE2UIWCN4KOiAReplace.Attoparsec.ByteStringReplace.Attoparsec.Text Data.List takeWhile Data.TextbreakOnData.Attoparsec.ByteStringmatch Data.Monoidmconcat Data.Tuplefst Data.FunctionidControl.Monad.Combinators manyTill_anyWord8takeTillData.Attoparsec.Internal.TypesParserPosData.Attoparsec.TextanyCharbreakCapsplitCap streamEdit streamEditTanyTillsepCap findAllCapfindAllbase GHC.MaybeJustGHC.Base<> Data.EitherRightLeftData.Bifunctorsecond Data.Functor<$>ghc-prim GHC.TypesIO getOffsetadvance*attoparsec-0.13.2.4-A8URAKFkG7PJq8yjGaCPMR#Data.Attoparsec.ByteString.InternalData.Attoparsec.Internal endOfInput substringGHC.Listtake