!  2019 James BrockBSD2"James Brock <jamesbrock@gmail.com>None_Ereplace-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.Output@The input stream is separated and output int 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.NotesThis sepCapN parser combinator is the basis for all of the other features of this module.It 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.htmlparsers8 but, importantly, it returns the parsed result of the sep, parser instead of throwing it away, like  ehttp://hackage.haskell.org/package/parser-combinators/docs/Control-Monad-Combinators.html#v:manyTill_ manyTill_.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-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.QThis function is not a parser combinator,  it is a way to run a parser , like  or .*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-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-attoparsecThe pattern matching parser sepreplace-attoparsecThe pattern matching parser sepreplace-attoparsecThe pattern matching parser sepreplace-attoparsec The parser sep for the pattern of interest.replace-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 edited.replace-attoparsec The parser sep for the pattern of interest.replace-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 edited.2019 James BrockBSD2"James Brock <jamesbrock@gmail.com>None_{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.Output@The input stream is separated and output int 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.NotesThis sepCapN parser combinator is the basis for all of the other features of this module.It 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.htmlparsers8 but, importantly, it returns the parsed result of the sep, parser instead of throwing it away, like  ehttp://hackage.haskell.org/package/parser-combinators/docs/Control-Monad-Combinators.html#v:manyTill_ manyTill_.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-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.QThis function is not a parser combinator,  it is a way to run a parser , like  or .*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-attoparsecGet the    current offset    in the stream.$Note that this is not the number of Hs which have been consumed, rather it is an offset into the underlying 7 array buffer, so you cannot use it as an argument to  . But you can use it as an argument to . ,https://github.com/bos/attoparsec/issues/101>  & you know you're in an uncomfortable state of sin :-)   bosreplace-attoparsecThe pattern matching parser sepreplace-attoparsecThe pattern matching parser sepreplace-attoparsecThe pattern matching parser sepreplace-attoparsec The parser sep for the pattern of interest.replace-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 edited. replace-attoparsec The parser sep for the pattern of interest.replace-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 edited.   !"#$$%1replace-attoparsec-1.2.1.0-CxmoqGQzFvsIXeOv15ledFReplace.Attoparsec.ByteStringReplace.Attoparsec.TextData.Attoparsec.ByteStringmatchparse parseOnly Data.Tuplefst Data.FunctionidData.Attoparsec.Internal.TypesParserPosData.Attoparsec.TextDataCharData.Text.InternalText Data.TextindextextsepCap findAllCapfindAll streamEdit streamEditTbase Data.EitherRightLeftData.Bifunctorsecondghc-prim GHC.TypesIO getOffset