úÎ!V#UI©2019 James BrockBSD2"James Brock <jamesbrock@gmail.com>NoneHSVX‡replace-megaparsecThe pattern matching parser sep©2019 James BrockBSD2"James Brock <jamesbrock@gmail.com>NoneHSVX¯replace-megaparsecThe pattern matching parser sep©2019 James BrockBSD2"James Brock <jamesbrock@gmail.com>None >HSVX_kUreplace-megaparsecSeparate and captureWParser combinator to find all of the non-overlapping ocurrences of the pattern parser sep in a text stream. The @ parser will always consume its entire input and can never fail.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.Special accelerated inputsZThere are specialization re-write rules to speed up this function when the input type is  Data.Text or Data.ByteString.Error parameterThe error type parameter e for sep should usually be  , because sep( fails on every token in a non-matching 3 section, so parser failures will not be reported.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-megaparsec6Find 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-megaparsecFind 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-megaparsec 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  (s,a) -> s.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   Type constraints6The type of the stream of text that is input must be Stream s such that  Tokens s ~ sp, because we want to output the same type of stream that was input. That requirement is satisfied for all the   instances included with Text.Megaparsec:  Data.Text, Data.Text.Lazy, Data.ByteString, Data.ByteString.Lazy, and  Data.String. We need the Monoid s instance so that we can   the output stream.The error type parameter e should usually be .replace-megaparsecStream editor transformerMonad transformer version of .Both the parser sep and the editor/ function run in the underlying monad context.If you want to do  operations in the editor function or the parser sep, then run this in .If you want the editor function or the parser sep< to remember some state, then run this in a stateful monad.replace-megaparsecThe pattern matching parser sepreplace-megaparsecThe pattern matching parser sepreplace-megaparsecThe pattern matching parser sepreplace-megaparsec The parser sep for the pattern of interest.replace-megaparsecThe editor$ function. Takes a parsed result of sep7 and returns a new stream section for the replacement.replace-megaparsec&The input stream of text to be edited.replace-megaparsec The parser sep for the pattern of interest.replace-megaparsecThe editor$ function. Takes a parsed result of sep7 and returns a new stream section for the replacement.replace-megaparsec&The input stream of text to be edited.   !"#1replace-megaparsec-1.3.2.0-DVtLdpS3AYS89pdOXmuvDI&Replace.Megaparsec.Internal.ByteString Replace.Megaparsec.Internal.TextReplace.MegaparsecDataVoid Data.Tuplefst Data.Functionid Data.MonoidmconcatsepCapByteString sepCapTextsepCap findAllCapfindAll streamEdit streamEditTbase Data.EitherRightLeft'megaparsec-8.0.0-BFw8gNuiOzWGglmtIkYt5XText.MegaparsecmatchData.Bifunctorsecondparse runParserTText.Megaparsec.StreamStreamghc-prim GHC.TypesIO