regex-do 3.0.1 → 3.1
raw patch · 21 files changed
+93/−78 lines, 21 filesdep ~arraydep ~basedep ~bytestring
Dependency ranges changed: array, base, bytestring, regex-base, regex-pcre, stringsearch, tagged, text
Files
- changelog.md +7/−0
- regex-do.cabal +6/−4
- src/Text/Regex/Do/Match/Latin.hs +2/−3
- src/Text/Regex/Do/Match/Matchf.hs +5/−4
- src/Text/Regex/Do/Match/Regex.hs +1/−1
- src/Text/Regex/Do/Match/Result.hs +2/−0
- src/Text/Regex/Do/Match/Utf8.hs +2/−2
- src/Text/Regex/Do/Replace/Latin.hs +0/−1
- src/Text/Regex/Do/Replace/Template.hs +2/−2
- src/Text/Regex/Do/Replace/Utf8.hs +0/−1
- src/Text/Regex/Do/Type/Convert.hs +1/−1
- src/Text/Regex/Do/Type/Do.hs +7/−29
- src/Text/Regex/Do/Type/Do_.hs +23/−0
- src/Text/Regex/Do/Type/Internal.hs +23/−0
- src/Text/Regex/Do/Type/MatchHint.hs +3/−21
- src/Text/Regex/Do/Type/Reexport.hs +4/−4
- test/TestRegex/TestFormat.hs +1/−1
- test/TestRegex/TestPcre.hs +1/−1
- test/TestRegex/TestReplace.hs +1/−1
- test/TestRegex/TestReplaceOpen.hs +1/−1
- test/TestRegex/TestReplaceUtf.hs +1/−1
changelog.md view
@@ -1,3 +1,10 @@+##### 3.1+ tidy up types: + + reexport Regex and other types in Text.Regex.Do.Type.Do++ merge Hint and other types to Text.Regex.Do.Type.Do+ ##### 3.0.1 fix changelog
regex-do.cabal view
@@ -1,5 +1,5 @@ name: regex-do-version: 3.0.1+version: 3.1 synopsis: PCRE wrapper description: format, search, replace (String | ByteString) with PCRE regex. Utf8-safe author: Imants Cekusins@@ -23,21 +23,23 @@ Text.Regex.Do.Replace.Utf8 Text.Regex.Do.Split Text.Regex.Do.Replace.Template- Text.Regex.Do.Type.Do Text.Regex.Do.Type.Convert Text.Regex.Do.Pad Text.Regex.Do.Replace.Open Text.Regex.Do.Type.Extract Text.Regex.Do.Match.Regex- Text.Regex.Do.Type.MatchHint Text.Regex.Do.Match.Latin Text.Regex.Do.Replace.Latin Text.Regex.Do.Match.Utf8 Text.Regex.Do.Replace.Fast+ Text.Regex.Do.Type.Do other-modules:+ Text.Regex.Do.Type.Reexport Text.Regex.Do.Match.Result Text.Regex.Do.Match.Matchf- Text.Regex.Do.Type.Reexport+ Text.Regex.Do.Type.Do_+ Text.Regex.Do.Type.MatchHint+ Text.Regex.Do.Type.Internal ghc-options: -fwarn-unused-imports
src/Text/Regex/Do/Match/Latin.hs view
@@ -11,14 +11,13 @@ R.extract -- | 'extract' is reexport from "Text.Regex.Base.RegexLike" ) where +import Data.Tagged import qualified Text.Regex.Base.RegexLike as R hiding (makeRegex) import Text.Regex.Do.Type.Do import Text.Regex.Do.Match.Matchf as F-import Text.Regex.PCRE.Wrap()-import Text.Regex.Do.Type.MatchHint import Text.Regex.Do.Match.Regex as R import Text.Regex.Do.Type.Reexport as Re-import Data.Tagged+import Text.Regex.Do.Type.Internal {- | === API changes:
src/Text/Regex/Do/Match/Matchf.hs view
@@ -1,13 +1,14 @@--- | __internal__ module, exposed only to show the instances+-- __internal__ module module Text.Regex.Do.Match.Matchf where -import Text.Regex.Do.Type.Do+import Data.Tagged+import Data.ByteString as B+import Text.Regex.Do.Type.Do_ import Text.Regex.Do.Type.Reexport as R import Text.Regex.Do.Match.Result as R import Text.Regex.Base.RegexLike as R import Text.Regex.Do.Type.MatchHint-import Data.Tagged-import Data.ByteString as B +import Text.Regex.Do.Type.Internal type R_ b = R.RegexLike R.Regex b
src/Text/Regex/Do/Match/Regex.hs view
@@ -5,7 +5,7 @@ import qualified Text.Regex.Base.RegexLike as R import qualified Text.Regex.Do.Type.Reexport as R import Data.ByteString-import Text.Regex.Do.Type.Do+import Text.Regex.Do.Type.Do hiding (Regex) import Text.Regex.Do.Match.Option import Data.List as L
src/Text/Regex/Do/Match/Result.hs view
@@ -3,6 +3,8 @@ import qualified Data.Array as A(elems) import Text.Regex.Base.RegexLike as R import Text.Regex.Do.Type.Do+import Text.Regex.Do.Type.Internal+ -- | match offset, length poslen::Functor f =>
src/Text/Regex/Do/Match/Utf8.hs view
@@ -10,16 +10,16 @@ ) where import Data.Tagged+import Data.ByteString import qualified Text.Regex.Base.RegexLike as R hiding (makeRegex) import Text.Regex.Do.Type.Do import Text.Regex.Do.Match.Matchf as F import Text.Regex.PCRE.Wrap() import Text.Regex.Do.Match.Regex as T-import Text.Regex.Do.Type.MatchHint import Text.Regex.Do.Match.Option import Text.Regex.Do.Type.Reexport as Re-import Data.ByteString import Text.Regex.Do.Type.Convert+import Text.Regex.Do.Type.Internal {- | * pattern: 'String', 'ByteString', 'Regex' compile 'Re.Regex' with 'Utf8' opt
src/Text/Regex/Do/Replace/Latin.hs view
@@ -12,7 +12,6 @@ import qualified Text.Regex.Do.Replace.Open as O import Text.Regex.Do.Match.Regex as T import Text.Regex.Do.Type.Extract-import Text.Regex.Do.Type.MatchHint {- | hint: 'All' | 'Once'
src/Text/Regex/Do/Replace/Template.hs view
@@ -60,9 +60,9 @@ Template a [a] where (<) t0 a0 = foldr_idx foldFn_idx t0 a0 {- ^ === index based- >>> ["цветы", "мороженное"] > "даме {0}, детям {1}" + >>> ["цветы", "мороженое"] > "даме {0}, детям {1}" - "даме цветы, детям мороженное"+ "даме цветы, детям мороженое" >>> "Polly {0} a {1}" < ["wants","cracker"]
src/Text/Regex/Do/Replace/Utf8.hs view
@@ -10,7 +10,6 @@ import Text.Regex.Do.Match.Matchf import qualified Text.Regex.Do.Replace.Open as O import Text.Regex.Do.Match.Regex as T-import Text.Regex.Do.Type.MatchHint import Text.Regex.Do.Type.Convert import Data.ByteString import Text.Regex.Do.Type.Extract
src/Text/Regex/Do/Type/Convert.hs view
@@ -3,7 +3,7 @@ import qualified Data.Text.Encoding as E import qualified Data.Text as T import Data.ByteString as B-import Text.Regex.Do.Type.Do+import Text.Regex.Do.Type.Do_ import Text.Regex.Base.RegexLike as R import Data.Array as A import Prelude as P
src/Text/Regex/Do/Type/Do.hs view
@@ -1,31 +1,9 @@-module Text.Regex.Do.Type.Do where--import Text.Regex.Base.RegexLike as R----- | see "Text.Regex.Do.Replace.Open" 'defaultReplacer' for example implementation-newtype GroupReplacer b = GroupReplacer (MatchArray -> ReplaceAcc b -> ReplaceAcc b) -- MatchArray -> acc -> acc--data ReplaceAcc b = ReplaceAcc {- acc::b, -- ^ content with some replacements made- pos_adj::Int {- ^ position adjustment: group replacement length may differ from replaced text length -}- }--instance Functor ReplaceAcc where- fmap fn0 r0 = r0 { acc = fn0 $ acc r0 }------ | Haystack-data Body b = Body b deriving (Functor) -- Bs, String-instance Applicative Body where- pure p0 = Body p0- (<*>) (Body f0) (Body a0) = Body $ f0 a0----- | Offset, Length-type PosLen = (MatchOffset, MatchLength)+module Text.Regex.Do.Type.Do + (module Text.Regex.Do.Type.Do_,+ module Text.Regex.Do.Type.MatchHint,+ module Text.Regex.Do.Type.Reexport) where -{-| 'Left' String returns regex construction error -}-type E a = Either String a+import Text.Regex.Do.Type.Do_+import Text.Regex.Do.Type.MatchHint+import Text.Regex.Do.Type.Reexport
+ src/Text/Regex/Do/Type/Do_.hs view
@@ -0,0 +1,23 @@+module Text.Regex.Do.Type.Do_ where++import Text.Regex.Base.RegexLike as R+++-- | see "Text.Regex.Do.Replace.Open" 'defaultReplacer' for example implementation+newtype GroupReplacer b = GroupReplacer (MatchArray -> ReplaceAcc b -> ReplaceAcc b) -- MatchArray -> acc -> acc++data ReplaceAcc b = ReplaceAcc {+ acc::b, -- ^ content with some replacements made+ pos_adj::Int {- ^ position adjustment: group replacement length may differ from replaced text length -}+ }++instance Functor ReplaceAcc where+ fmap fn0 r0 = r0 { acc = fn0 $ acc r0 }+++-- | Offset, Length+type PosLen = (MatchOffset, MatchLength)+++{-| 'Left' String returns regex construction error -}+type E a = Either String a
+ src/Text/Regex/Do/Type/Internal.hs view
@@ -0,0 +1,23 @@+module Text.Regex.Do.Type.Internal where+++class Hint hint where+ unhint::hint a -> a+ hint::a -> hint a++++instance Hint Test where+ unhint (Test a0) = a0+ hint = Test+++newtype Test a = Test a -- ^ test: does body match pattern?++++-- | Haystack+data Body b = Body b deriving (Functor) -- Bs, String+instance Applicative Body where+ pure p0 = Body p0+ (<*>) (Body f0) (Body a0) = Body $ f0 a0
src/Text/Regex/Do/Type/MatchHint.hs view
@@ -1,25 +1,15 @@ module Text.Regex.Do.Type.MatchHint where -newtype Test a = Test a -- ^ test: does body match pattern?+import Text.Regex.Do.Type.Internal++ newtype Once a = Once a -- ^ replace once deriving (Functor) newtype All a = All a -- ^ replace all deriving (Functor) -newtype PosLen' a = PosLen' a -- ^ once-newtype PosLen_ a = PosLen_ a -- ^ all --class Hint hint where- unhint::hint a -> a- hint::a -> hint a---instance Hint Test where- unhint (Test a0) = a0- hint = Test- instance Hint Once where unhint (Once a0) = a0 hint = Once@@ -27,14 +17,6 @@ instance Hint All where unhint (All a0) = a0 hint = All--instance Hint PosLen' where- unhint (PosLen' a0) = a0- hint = PosLen'--instance Hint PosLen_ where- unhint (PosLen_ a0) = a0- hint = PosLen_ instance Applicative Once where
src/Text/Regex/Do/Type/Reexport.hs view
@@ -1,9 +1,9 @@ -- | reexport common types from "Text.Regex.PCRE" module Text.Regex.Do.Type.Reexport (- W.Regex(..),- R.MatchArray(..),- W.CompOption(..),- W.ExecOption()+ W.Regex(..) -- | "Text.Regex.PCRE.Wrap" + ,R.MatchArray(..) -- | "Text.Regex.Base.RegexLike" + ,W.CompOption(..) -- | "Text.Regex.PCRE.Wrap"+ ,W.ExecOption() -- | "Text.Regex.PCRE.Wrap" ) where import Text.Regex.PCRE.ByteString as B (Regex)
test/TestRegex/TestFormat.hs view
@@ -30,7 +30,7 @@ it "list arg 0,0 >" $ [fn0 "перловка"] > (fn0 "на первое {0}, на второе {0}") `shouldBe` (fn0 "на первое перловка, на второе перловка") it "list arg 0,0 > 2" $- [fn0 "цветы", fn0 "мороженное"] > (fn0 "даме {0}, детям {1}") `shouldBe` (fn0 "даме цветы, детям мороженное")+ [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")
test/TestRegex/TestPcre.hs view
@@ -1,7 +1,7 @@ module TestRegex.TestPcre where import Test.Hspec-import Text.Regex.Do.Type.Do as M+import Text.Regex.Do.Type.Do_ as M import Text.Regex.Do.Match.Latin as M import Text.Regex.Do.Match.Utf8 as U import Text.Regex.Do.Type.Convert
test/TestRegex/TestReplace.hs view
@@ -2,7 +2,7 @@ module TestRegex.TestReplace where import Test.Hspec-import Text.Regex.Do.Type.Do+import Text.Regex.Do.Type.Do_ import Text.Regex.Do.Replace.Latin as R import qualified Text.Regex.Do.Replace.Utf8 as U
test/TestRegex/TestReplaceOpen.hs view
@@ -3,7 +3,7 @@ import Test.Hspec import Text.Regex.Do.Replace.Open as O-import Text.Regex.Do.Type.Do+import Text.Regex.Do.Type.Do_ import Data.Text import Text.Regex.Do.Type.Convert() import Debug.Trace
test/TestRegex/TestReplaceUtf.hs view
@@ -2,7 +2,7 @@ module TestRegex.TestReplaceUtf where import Test.Hspec-import Text.Regex.Do.Type.Do+import Text.Regex.Do.Type.Do_ import Data.ByteString import Text.Regex.Do.Type.Convert import Text.Regex.Do.Replace.Utf8 as U