replace-megaparsec 1.3.1.0 → 1.3.2.0
raw patch · 6 files changed
+20/−14 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +9/−9
- replace-megaparsec.cabal +2/−2
- src/Replace/Megaparsec.hs +3/−3
- tests/TestByteString.hs +2/−0
- tests/TestString.hs +2/−0
- tests/TestText.hs +2/−0
README.md view
@@ -63,7 +63,6 @@ the regular expression says it has found a numeric string but the string-to-number conversion function fails. A typed parser will perform both the pattern match and the conversion, so it will never be in that situation.- [Parse, don't validate.](https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/) * Regular expressions are only able to pattern-match@@ -108,7 +107,7 @@ number with a prefix `"0x"`, and sections which can't. Parse the numbers. ```haskell-let hexparser = chunk "0x" >> hexadecimal :: Parsec Void String Integer+let hexparser = chunk "0x" *> hexadecimal :: Parsec Void String Integer parseTest (sepCap hexparser) "0xA 000 0xFFFF" ``` ```haskell@@ -121,7 +120,7 @@ the parsed number. ```haskell-let hexparser = chunk "0x" >> hexadecimal :: Parsec Void String Integer+let hexparser = chunk "0x" *> hexadecimal :: Parsec Void String Integer parseTest (findAll hexparser) "0xA 000 0xFFFF" ``` ```haskell@@ -134,7 +133,7 @@ parses as a hexadecimal number. ```haskell-let hexparser = chunk "0x" >> hexadecimal :: Parsec Void String Integer+let hexparser = chunk "0x" *> hexadecimal :: Parsec Void String Integer parseTest (findAllCap hexparser) "0xA 000 0xFFFF" ``` ```haskell@@ -150,7 +149,7 @@ ```haskell import Data.Either let spaceoffset = getOffset <* space1 :: Parsec Void String Int-parseTest (return . rights =<< sepCap spaceoffset) " a b "+parseTest (pure . rights =<< sepCap spaceoffset) " a b " ``` ```haskell [0,2,5]@@ -163,13 +162,14 @@ expression. We can express the pattern with a recursive parser. ```haskell+import Data.Functor let parens :: Parsec Void String () parens = do char '(' manyTill (void (noneOf "()") <|> void parens) (char ')')- return ()+ pure () parseTest (findAll parens) "(()) (()())" ```@@ -216,7 +216,7 @@ combinator. ```haskell-let hexparser = chunk "0x" >> hexadecimal :: Parsec Void String Integer+let hexparser = chunk "0x" *> hexadecimal :: Parsec Void String Integer streamEdit (match hexparser) (\(s,r) -> if r<=16 then show r else s) "0xA 000 0xFFFF" ``` ```haskell@@ -407,8 +407,8 @@ The premise of this library is that monadic parsers are great for finding small signal patterns in a stream of otherwise noisy text. - There is a reluctance to forego the speedup opportunities afforded by restricting- ourselves to regular grammars, but this is an old superstition about+ Our reluctance to forego the speedup opportunities afforded by restricting+ ourselves to regular grammars is an old superstition about opportunities which [remain mostly unexploited anyway](https://swtch.com/~rsc/regexp/regexp1.html). The performance compromise of allowing stack memory allocation (a.k.a. pushdown
replace-megaparsec.cabal view
@@ -1,7 +1,7 @@ name: replace-megaparsec-version: 1.3.1.0+version: 1.3.2.0 cabal-version: 1.18-synopsis: Find, replace, and edit text patterns with Megaparsec parsers+synopsis: Find, replace, and edit text patterns with Megaparsec parsers (instead of regex) homepage: https://github.com/jamesdbrock/replace-megaparsec bug-reports: https://github.com/jamesdbrock/replace-megaparsec/issues license: BSD2
src/Replace/Megaparsec.hs view
@@ -97,7 +97,7 @@ -- === Special accelerated inputs -- -- There are specialization re-write rules to speed up this function when--- the input type is "Data.Text" or "Data.Bytestring".+-- the input type is "Data.Text" or "Data.ByteString". -- -- === Error parameter --@@ -248,8 +248,8 @@ -- with "Text.Megaparsec": -- "Data.Text", -- "Data.Text.Lazy",--- "Data.Bytestring",--- "Data.Bytestring.Lazy",+-- "Data.ByteString",+-- "Data.ByteString.Lazy", -- and "Data.String". -- -- We need the @Monoid s@ instance so that we can 'Data.Monoid.mconcat' the output
tests/TestByteString.hs view
@@ -47,6 +47,7 @@ ("a") ([Left "a"]) #endif+ , Test $ runParserTest "empty input" (sepCap (fail "" :: Parser ())) "" [] , Test $ streamEditTest "x to o" (string "x" :: Parser B.ByteString) (const "o") "x x x" "o o o"@@ -56,6 +57,7 @@ , Test $ streamEditTest "ordering" (string "456" :: Parser B.ByteString) (const "ABC") "123456789" "123ABC789"+ , Test $ streamEditTest "empty input" (match (fail "" :: Parser ())) (fst) "" "" ] where runParserTest nam p input expected = TestInstance
tests/TestString.hs view
@@ -47,6 +47,7 @@ (findAll ((takeWhileP Nothing (=='𝅘𝅥𝅯') :: Parser String))) ("𝄞𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥") [Left "𝄞𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥", Right "𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯", Left "𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥"]+ , Test $ runParserTest "empty input" (sepCap (fail "" :: Parser ())) "" [] , Test $ streamEditTest "x to o" (string "x" :: Parser String) (const "o") "x x x" "o o o"@@ -56,6 +57,7 @@ , Test $ streamEditTest "ordering" (string "456" :: Parser String) (const "ABC") "123456789" "123ABC789"+ , Test $ streamEditTest "empty input" (match (fail "" :: Parser ())) (fst) "" "" ] where runParserTest nam p input expected = TestInstance
tests/TestText.hs view
@@ -49,6 +49,7 @@ (findAll ((takeWhileP Nothing (=='𝅘𝅥𝅯') :: Parser T.Text))) ("𝄞𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥" :: T.Text) [Left "𝄞𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥", Right "𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯𝅘𝅥𝅯", Left "𝅘𝅥𝅘𝅥𝅘𝅥𝅘𝅥"]+ , Test $ runParserTest "empty input" (sepCap (fail "" :: Parser ())) "" [] , Test $ streamEditTest "x to o" (string "x" :: Parser T.Text) (const "o") "x x x" "o o o"@@ -58,6 +59,7 @@ , Test $ streamEditTest "ordering" (string "456" :: Parser T.Text) (const "ABC") "123456789" "123ABC789"+ , Test $ streamEditTest "empty input" (match (fail "" :: Parser ())) (fst) "" "" ] where runParserTest nam p input expected = TestInstance