regex-do 3.0 → 3.0.1
raw patch · 8 files changed
+29/−17 lines, 8 filesdep −mtlPVP ok
version bump matches the API change (PVP)
Dependencies removed: mtl
API changes (from Hackage documentation)
Files
- changelog.md +8/−0
- regex-do.cabal +1/−3
- src/Text/Regex/Do/Match/Latin.hs +2/−2
- src/Text/Regex/Do/Match/Utf8.hs +3/−3
- src/Text/Regex/Do/Replace/Latin.hs +1/−1
- src/Text/Regex/Do/Replace/Template.hs +10/−6
- src/Text/Regex/Do/Replace/Utf8.hs +2/−2
- test/TestRegex/TestFormat.hs +2/−0
changelog.md view
@@ -1,9 +1,17 @@+##### 3.0.1+ fix changelog + ##### 3.0 *API overhaul*+ minimize use of newtypes+ regex-constructing functions catch error, return Either String a+ Format is now Replace.Template+ fix bug in ReplaceOpen.getGroup + hide Matchf ##### 2.6.2
regex-do.cabal view
@@ -1,5 +1,5 @@ name: regex-do-version: 3.0+version: 3.0.1 synopsis: PCRE wrapper description: format, search, replace (String | ByteString) with PCRE regex. Utf8-safe author: Imants Cekusins@@ -47,7 +47,6 @@ stringsearch, bytestring, tagged,- mtl, array, text @@ -103,7 +102,6 @@ regex-pcre, tagged, stringsearch,- mtl, bytestring, array, text,
src/Text/Regex/Do/Match/Latin.hs view
@@ -1,7 +1,7 @@ {- | although sometimes funs in Ascii modules work with non-ascii text (as some examples show), for reliable results with Utf8 pattern or body,- use "Text.Regex.Do.Pcre.Match.Utf8"+ use "Text.Regex.Do.Match.Utf8" see also "Text.Regex.Base.RegexLike" -} @@ -42,7 +42,7 @@ * ['PosLen'] - precompiled Regex may be used as pattern too. see "Text.Regex.Do.Pcre.Match.Utf8" -}+ precompiled Regex may be used as pattern too. see "Text.Regex.Do.Match.Utf8" -} class MatchOnce pattern body out where (~?)::pattern -> body -> out
src/Text/Regex/Do/Match/Utf8.hs view
@@ -1,6 +1,6 @@ {- | see "Text.Regex.Base.RegexLike" - see "Text.Regex.Do.Pcre.Match.Latin" for API changes+ see "Text.Regex.Do.Match.Latin" for API changes __'toByteString'__ converts String to utf8 'ByteString' -} module Text.Regex.Do.Match.Utf8@@ -55,8 +55,8 @@ ==== precompiled regex as pattern @ -let rx1 = makeRegexOpt (toByteString "左") [Utf8] [] -- add options as needed- m1 = rx1 -? (toByteString "100メートル左折後、左")::[ByteString]+let Right rx1 = makeRegexOpt (toByteString "左") [Utf8] [] -- add options as needed+ m1 = rx1 ~? (toByteString "100メートル左折後、左")::[ByteString] m1 `shouldBe` [toByteString "左"] @ -}
src/Text/Regex/Do/Replace/Latin.hs view
@@ -1,5 +1,5 @@ {- | for reliable results with Utf8 pattern or body,- use "Text.Regex.Do.Pcre.Replace.Utf8" -}+ use "Text.Regex.Do.Replace.Utf8" -} module Text.Regex.Do.Replace.Latin (Replace(..)) where
src/Text/Regex/Do/Replace/Template.hs view
@@ -16,7 +16,7 @@ other placeholders may be implemented with - "Text.Regex.Do.Pcre.Ascii.Replace" or "Text.Regex.Do.Pcre.Utf8.Replace" + "Text.Regex.Do.Replace.Latin" or "Text.Regex.Do.Replace.Utf8" to avoid clash with 'Prelude': @@ -60,13 +60,17 @@ Template a [a] where (<) t0 a0 = foldr_idx foldFn_idx t0 a0 {- ^ === index based- >>> ["перловка"] > "на первое {0}, на второе {0}" -- "на первое перловка, на второе перловка"+ >>> ["цветы", "мороженное"] > "даме {0}, детям {1}" + + "даме цветы, детям мороженное" - >>> "Polly {0} a {1}" < ["got","cracker"]+ >>> "Polly {0} a {1}" < ["wants","cracker"] - "Polly got a cracker"+ "Polly wants a cracker"+ + >>> ["перловка"] > "на первое {0}, на второе {0}"+ + "на первое перловка, на второе перловка" -} foldFn_idx::ReplaceOne k v =>
src/Text/Regex/Do/Replace/Utf8.hs view
@@ -1,4 +1,4 @@-{- | see also "Text.Regex.Do.Pcre.Replace.Latin"+{- | see also "Text.Regex.Do.Replace.Latin" __'toByteString'__ converts String to 'ByteString' -} @@ -19,7 +19,7 @@ import Text.Regex.Do.Match.Option -{- | see "Text.Regex.Do.Pcre.Replace.Latin" for implemented types+{- | see "Text.Regex.Do.Replace.Latin" for implemented types 'GroupReplacer' is implemented only for 'ByteString' -}
test/TestRegex/TestFormat.hs view
@@ -29,6 +29,8 @@ (fn0 "на первое {0}, на второе {0}") < [fn0 "перловка"] `shouldBe` (fn0 "на первое перловка, на второе перловка") it "list arg 0,0 >" $ [fn0 "перловка"] > (fn0 "на первое {0}, на второе {0}") `shouldBe` (fn0 "на первое перловка, на второе перловка")+ it "list arg 0,0 > 2" $+ [fn0 "цветы", fn0 "мороженное"] > (fn0 "даме {0}, детям {1}") `shouldBe` (fn0 "даме цветы, детям мороженное") it "list arg 0,1" $ do (fn0 "Polly {0} a {1}") < [fn0 "gets",fn0 "cracker"] `shouldBe` (fn0 "Polly gets a cracker") (fn0 "{10} {15} {21}") < (idx0 <$> [0..22]) `shouldBe` (fn0 "10 15 21")