regex-examples 0.3.0.0 → 0.5.0.0
raw patch · 22 files changed
+460/−185 lines, 22 filesdep ~regex
Dependency ranges changed: regex
Files
- README.markdown +1/−1
- changelog +9/−0
- examples/re-gen-cabals.lhs +40/−14
- examples/re-gen-modules.lhs +9/−0
- examples/re-include.lhs +14/−0
- examples/re-nginx-log-processor.lhs +12/−0
- examples/re-prep.lhs +13/−1
- examples/re-tests.lhs +233/−98
- lib/cabal-masters/library-incl.cabal +2/−3
- lib/mega-regex.cabal +19/−20
- lib/version.txt +1/−1
- regex-examples.cabal +17/−17
- src/Text/RE/PCRE/ByteString.hs +9/−3
- src/Text/RE/PCRE/ByteString/Lazy.hs +9/−3
- src/Text/RE/PCRE/Sequence.hs +9/−3
- src/Text/RE/PCRE/String.hs +9/−3
- src/Text/RE/TDFA/ByteString.hs +9/−3
- src/Text/RE/TDFA/ByteString/Lazy.hs +9/−3
- src/Text/RE/TDFA/Sequence.hs +9/−3
- src/Text/RE/TDFA/String.hs +9/−3
- src/Text/RE/TDFA/Text.hs +9/−3
- src/Text/RE/TDFA/Text/Lazy.hs +9/−3
README.markdown view
@@ -49,7 +49,7 @@ ☒ 2017-02-26 v0.3.0.0 [API adjustments](https://github.com/iconnect/regex/milestone/2) - ☐ 2017-03-05 v0.5.0.0 [Ready for review: tutorials and examples finalized](https://github.com/iconnect/regex/milestone/6)+ ☒ 2017-03-05 v0.5.0.0 [Ready for review: API, tutorials and examples finalized](https://github.com/iconnect/regex/milestone/6) ☐ 2017-03-20 v1.0.0.0 [First stable release](https://github.com/iconnect/regex/milestone/3)
changelog view
@@ -1,5 +1,14 @@ -*-change-log-*- +0.5.0.0 Chris Dornan <chris.dornan@irisconnect.co.uk> 2017-03-05+ * Fix inter-operation of =~ & =~~ and named captures (#55)+ * Add escaping functions (#37)+ * Test Hackage release tarballs on Travis CI (#51)+ * Fix up template replace ordinals (#52)+ * Complete the web site (#39)+ * Complete the Tutorial, Tests and Examples (#38)+ * Complete narrative in literate modules (#8)+ 0.3.0.0 Chris Dornan <chris.dornan@irisconnect.co.uk> 2017-02-26 * Clean up API to use camelCase conventions * Use -Werror in development and testing, -Warn for Hackage
examples/re-gen-cabals.lhs view
@@ -1,3 +1,15 @@+Regex Cabal Gen+===============++This tool generates the cabal files for the regex and regex-examples+packages as well as the cabal file for the development tree+(contaiing the combined targets of both packages). In addition it+contains scripts for bumping the version number and generating the+Hackage releases.++The tool is self-testing: run it with no arguments (or `cabal test`).++ \begin{code} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RecordWildCards #-}@@ -26,22 +38,32 @@ import TestKit import Text.Printf import Text.RE.TDFA.ByteString.Lazy+import Text.RE.TDFA.Text as T main :: IO () main = do (pn,as) <- (,) <$> getProgName <*> getArgs case as of- [] -> test- ["test"] -> test- ["sdist"] -> sdist- ["gen"] -> do+ [] -> test+ ["test"] -> test+ ["bump-version",vrn] -> bumpVersion vrn+ ["sdist"] -> sdist+ ["gen"] -> do gen "lib/cabal-masters/mega-regex.cabal" "lib/mega-regex.cabal" gen "lib/cabal-masters/regex.cabal" "lib/regex.cabal" gen "lib/cabal-masters/regex-examples.cabal" "lib/regex-examples.cabal" establish "mega-regex" "regex"- _ -> do- hPutStrLn stderr $ "usage: " ++ pn ++ " [test|sdist|gen]"+ _ -> do+ let prg = ((" "++pn++" ")++)+ hPutStr stderr $ unlines+ [ "usage:"+ , prg "--help"+ , prg "[test]"+ , prg "bump-version <version>"+ , prg "sdist"+ , prg "gen"+ ] exitWith $ ExitFailure 1 test :: IO ()@@ -224,7 +246,9 @@ establish "mega-regex" "regex" vrn_t <- T.pack . presentVrn <$> readCurrentVersion smy_t <- summary- SH.shelly $ SH.verbosely $+ SH.shelly $ SH.verbosely $ do+ SH.run_ "git" ["add","--all"]+ SH.run_ "git" ["commit","-m",vrn_t<>": "<>smy_t] SH.run_ "git" ["tag",vrn_t,"-m",smy_t] sdist' :: T.Text -> IO ()@@ -232,14 +256,16 @@ establish nm nm SH.shelly $ SH.verbosely $ do SH.cp readme "README.markdown"- SH.run_ "cabal" ["clean"]- SH.run_ "cabal" ["configure"]- SH.run_ "cabal" ["sdist"]- vrn <- SH.liftIO readCurrentVersion- let tb = nm<>"-"<>T.pack(presentVrn vrn)<>".tar.gz"- SH.cp (SH.fromText $ "dist/"<>tb) $ SH.fromText $ "releases/"<>tb+ SH.run_ "stack" ["sdist","--stack-yaml","stack-8.0.yaml"]+ (pth,tb) <- analyse_so <$> SH.lastStderr+ SH.cp (SH.fromText $ pth) $ SH.fromText $ "releases/"<>tb where- readme = SH.fromText $ "lib/README-"<>nm<>".md"+ readme = SH.fromText $ "lib/README-"<>nm<>".md"++ analyse_so so = (mtch!$$[cp|pth|],mtch!$$[cp|tb|])+ where+ mtch = so T.?=~+ [re|^.*Wrote sdist tarball to ${pth}(.*${tb}(regex-.*\.tar\.gz))$|] establish :: T.Text -> T.Text -> IO () establish nm nm' = SH.shelly $ SH.verbosely $ do
examples/re-gen-modules.lhs view
@@ -1,3 +1,12 @@+Regex Module Gen+================++All of the modules that make up the API are generated from the+`Text.RE.TDFA.ByteString.Lazy` module using this script.++The tool is self-testing: run it with no arguments (or `cabal test`).++ \begin{code} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE TemplateHaskell #-}
examples/re-include.lhs view
@@ -1,3 +1,17 @@+Example: Include Processor+==========================++This example looks for lines like++```+%include "lib/md/load-tutorial-cabal-incl.md"+```++on its input and replaces them with the contents of the names file.++The tool is self-testing: run it with no arguments (or `cabal test`).++ \begin{code} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RecordWildCards #-}
examples/re-nginx-log-processor.lhs view
@@ -1,3 +1,15 @@+Example: NGINX Log Processor+============================++This example program reads lines from NGINX error-log files and+access-log files converts them into a unified output format.++It is an example of developing REs at scale using macros with+the regex test bench.++The tool is self-testing: run it with no arguments (or `cabal test`).++ \begin{code} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RecordWildCards #-}
examples/re-prep.lhs view
@@ -1,3 +1,14 @@+Regex (Page) Prep+=================++This tool turns the markdown and literate Haskell into the HTML that+makes up the website and the README.md for GitHub and for Hackage+(based on the index.md for the website) and the test suite based on+the tutorial.++The tool is self-testing: run it with no arguments (or `cabal test`).++ \begin{code} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RecordWildCards #-}@@ -23,6 +34,7 @@ import qualified Shelly as SH import System.Directory import System.Environment+import System.IO import TestKit import Text.Heredoc import Text.RE.Edit@@ -53,7 +65,7 @@ usage = do pnm <- getProgName let prg = ((" "++pnm++" ")++)- putStr $ unlines+ hPutStr stderr $ unlines [ "usage:" , prg "--help" , prg "[test]"
examples/re-tests.lhs view
@@ -1,3 +1,13 @@+Regex Test Suite+================++All of the regex exampes are self-testing and together make up the+regex test suite run during development and over each release of the+test suite. But here we have the unit an small-check tests used to+systematically probe the library for weak points and guard against+regressions.++ \begin{code} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RecordWildCards #-}@@ -22,6 +32,7 @@ import Data.String import qualified Data.Text as T import qualified Data.Text.Lazy as LT+import Data.Typeable import Language.Haskell.TH.Quote import Prelude.Compat import Test.SmallCheck.Series@@ -33,6 +44,7 @@ import qualified Text.Regex.TDFA as TDFA_ import Text.RE+import Text.RE.Internal.AddCaptureNames import Text.RE.Internal.NamedCaptures import Text.RE.Internal.PreludeMacros import Text.RE.Internal.QQ@@ -51,8 +63,10 @@ import qualified Text.RE.TDFA.Sequence as T_SQ import qualified Text.RE.TDFA.Text as T_TX import qualified Text.RE.TDFA.Text.Lazy as TLTX+\end{code} +\begin{code} main :: IO () main = defaultMain $ testGroup "Tests"@@ -63,9 +77,15 @@ , options_tests , namedCapturesTestTree , many_tests+ , escapeTests+ , add_capture_names_tests , misc_tests ]+\end{code} ++\begin{code}+-- | check that our self-testing macro environments are good prelude_tests :: TestTree prelude_tests = testGroup "Prelude" [ tc TDFA TDFA.preludeEnv@@ -76,93 +96,113 @@ testCase (show rty) $ do dumpMacroTable "macros" rty m_env assertBool "testMacroEnv" =<< testMacroEnv "prelude" rty m_env+\end{code} ++Core Match/Replace Tests+------------------------++<h3>test vectors</h3>++The core tests rely on these simple test vectors.++\begin{code}+-- | our standard test strings str_, str' :: String str_ = "a bbbb aa b" str' = "foo" +-- | standard test REs regex_, regex_alt :: RE regex_ = [re|(a+) (b+)|] regex_alt = [re|(a+)|(b+)|] +-- | golden matches result 1 regex_str_matches :: Matches String regex_str_matches = Matches- { matchesSource = "a bbbb aa b"+ { matchesSource = str_ , allMatches = [ regex_str_match , regex_str_match_2 ] } +-- | golden match result 1 regex_str_match :: Match String regex_str_match = Match- { matchSource = "a bbbb aa b"+ { matchSource = str_ , captureNames = noCaptureNames , matchArray = array (0,2)- [ (0,Capture {captureSource = "a bbbb aa b", capturedText = "a bbbb", captureOffset = 0, captureLength = 6})- , (1,Capture {captureSource = "a bbbb aa b", capturedText = "a" , captureOffset = 0, captureLength = 1})- , (2,Capture {captureSource = "a bbbb aa b", capturedText = "bbbb" , captureOffset = 2, captureLength = 4})+ [ (0,Capture {captureSource = str_, capturedText = "a bbbb", captureOffset = 0, captureLength = 6})+ , (1,Capture {captureSource = str_, capturedText = "a" , captureOffset = 0, captureLength = 1})+ , (2,Capture {captureSource = str_, capturedText = "bbbb" , captureOffset = 2, captureLength = 4}) ] } +-- | golden match result 2 regex_str_match_2 :: Match String regex_str_match_2 = Match- { matchSource = "a bbbb aa b"+ { matchSource = str_ , captureNames = noCaptureNames , matchArray = array (0,2)- [ (0,Capture {captureSource = "a bbbb aa b", capturedText = "aa b", captureOffset = 7 , captureLength = 4})- , (1,Capture {captureSource = "a bbbb aa b", capturedText = "aa" , captureOffset = 7 , captureLength = 2})- , (2,Capture {captureSource = "a bbbb aa b", capturedText = "b" , captureOffset = 10, captureLength = 1})+ [ (0,Capture {captureSource = str_, capturedText = "aa b", captureOffset = 7 , captureLength = 4})+ , (1,Capture {captureSource = str_, capturedText = "aa" , captureOffset = 7 , captureLength = 2})+ , (2,Capture {captureSource = str_, capturedText = "b" , captureOffset = 10, captureLength = 1}) ] } +-- | golden match result 2 regex_alt_str_matches :: Matches String regex_alt_str_matches = Matches- { matchesSource = "a bbbb aa b"+ { matchesSource = str_ , allMatches = [ Match- { matchSource = "a bbbb aa b"+ { matchSource = str_ , captureNames = noCaptureNames , matchArray = array (0,2)- [ (0,Capture {captureSource = "a bbbb aa b", capturedText = "a", captureOffset = 0, captureLength = 1})- , (1,Capture {captureSource = "a bbbb aa b", capturedText = "a", captureOffset = 0, captureLength = 1})- , (2,Capture {captureSource = "a bbbb aa b", capturedText = "", captureOffset = -1, captureLength = 0})+ [ (0,Capture {captureSource = str_, capturedText = "a", captureOffset = 0, captureLength = 1})+ , (1,Capture {captureSource = str_, capturedText = "a", captureOffset = 0, captureLength = 1})+ , (2,Capture {captureSource = str_, capturedText = "", captureOffset = -1, captureLength = 0}) ] } , Match- { matchSource = "a bbbb aa b"+ { matchSource = str_ , captureNames = noCaptureNames , matchArray = array (0,2)- [ (0,Capture {captureSource = "a bbbb aa b", capturedText = "bbbb", captureOffset = 2 , captureLength = 4})- , (1,Capture {captureSource = "a bbbb aa b", capturedText = "" , captureOffset = -1, captureLength = 0})- , (2,Capture {captureSource = "a bbbb aa b", capturedText = "bbbb", captureOffset = 2 , captureLength = 4})+ [ (0,Capture {captureSource = str_, capturedText = "bbbb", captureOffset = 2 , captureLength = 4})+ , (1,Capture {captureSource = str_, capturedText = "" , captureOffset = -1, captureLength = 0})+ , (2,Capture {captureSource = str_, capturedText = "bbbb", captureOffset = 2 , captureLength = 4}) ] } , Match- { matchSource = "a bbbb aa b"+ { matchSource = str_ , captureNames = noCaptureNames , matchArray = array (0,2)- [ (0,Capture {captureSource = "a bbbb aa b", capturedText = "aa", captureOffset = 7 , captureLength = 2})- , (1,Capture {captureSource = "a bbbb aa b", capturedText = "aa", captureOffset = 7 , captureLength = 2})- , (2,Capture {captureSource = "a bbbb aa b", capturedText = "" , captureOffset = -1, captureLength = 0})+ [ (0,Capture {captureSource = str_, capturedText = "aa", captureOffset = 7 , captureLength = 2})+ , (1,Capture {captureSource = str_, capturedText = "aa", captureOffset = 7 , captureLength = 2})+ , (2,Capture {captureSource = str_, capturedText = "" , captureOffset = -1, captureLength = 0}) ] } , Match- { matchSource = "a bbbb aa b"+ { matchSource = str_ , captureNames = noCaptureNames , matchArray = array (0,2)- [ (0,Capture {captureSource = "a bbbb aa b", capturedText = "b", captureOffset = 10, captureLength = 1})- , (1,Capture {captureSource = "a bbbb aa b", capturedText = "" , captureOffset = -1, captureLength = 0})- , (2,Capture {captureSource = "a bbbb aa b", capturedText = "b", captureOffset = 10, captureLength = 1})+ [ (0,Capture {captureSource = str_, capturedText = "b", captureOffset = 10, captureLength = 1})+ , (1,Capture {captureSource = str_, capturedText = "" , captureOffset = -1, captureLength = 0})+ , (2,Capture {captureSource = str_, capturedText = "b", captureOffset = 10, captureLength = 1}) ] } ] }+\end{code} +<h3>testing the compileRegex functions</h3>++\begin{code} parsing_tests :: TestTree parsing_tests = testGroup "Parsing" [ testCase "complete check (matchM/ByteString)" $ do@@ -172,7 +212,11 @@ r <- compileRegex () $ reSource regex_ assertEqual "matched" True $ matched $ T.pack str_ ?=~ r ]+\end{code} +<h3>core tests</h3>++\begin{code} core_tests :: TestTree core_tests = testGroup "Match" [ testCase "text (=~~Text.Lazy)" $ do@@ -201,7 +245,11 @@ let mtchs = str' =~ regex_ :: Matches String assertEqual "not.anyMatches" False $ anyMatches mtchs ]+\end{code} +<h3>testing the replace functions at different types</h3>++\begin{code} replaceMethodstests :: TestTree replaceMethodstests = testGroup "Replace" [ testCase "String/single" $ do@@ -253,7 +301,11 @@ packE (show_co j) <> ":" <> capturedText <> ")" show_co (CaptureOrdinal j) = show j+\end{code} +<h3>Testing The Options</h3>++\begin{code} options_tests :: TestTree options_tests = testGroup "Simple Options" [ testGroup "TDFA Simple Options"@@ -283,7 +335,12 @@ ] where s = "0a\nbb\nFe\nA5" :: String+\end{code} ++<h3>Exercising Our Many APIs</h3>++\begin{code} many_tests :: TestTree many_tests = testGroup "Many Tests" [ testCase "PCRE a" $ test (PCRE.*=~) (PCRE.?=~) (PCRE.=~) (PCRE.=~~) matchOnce matchMany id re_pcre@@ -332,7 +389,153 @@ re_tdfa = fromMaybe oops $ TDFA.compileRegex () "[0-9]{4}-[0-9]{2}-[0-9]{2}" oops = error "many_tests"+\end{code} ++Testing the RE Escape Functions+-------------------------------++\begin{code}+escapeTests :: TestTree+escapeTests = testGroup "Escape Tests"+ [ testGroup "PCRE"+ [ testCase "Escaping empty string" $+ assertBool "empty string" $+ tst P_ST.escape (P_ST.?=~) ""+ , testCase "Escaping RE metacharacters" $+ assertBool "metacharacters" $+ tst P_ST.escape (P_ST.?=~) metacharacters+ , localOption (SmallCheckDepth 6) $+ SC.testProperty "matched $ <s> ?=~ [re|^escape(<s>)$|]" $+ tst P_ST.escape (P_ST.?=~)+ ]+ , testGroup "TDFA"+ [ testCase "Escaping empty string" $+ assertBool "empty string" $+ tst T_ST.escape (T_ST.?=~) ""+ , testCase "Escaping RE metacharacters" $+ assertBool "metacharacters" $+ tst T_ST.escape (T_ST.?=~) metacharacters+ , localOption (SmallCheckDepth 6) $+ SC.testProperty "matched $ <s> ?=~ [re|^escape(<s>)$|]" $+ tst T_ST.escape (T_ST.?=~)+ ]+ ]+ where+ tst :: ((String->String)->String->a)+ -> (String->a->Match String)+ -> String+ -> Bool+ tst esc (%=~) s = matched $ s %=~ esc (("^" ++) . (++ "$")) s++ metacharacters :: String+ metacharacters = "^\\.|*+?()[]{}$"+\end{code}+++Named Capture Tests+-------------------++\begin{code}+namedCapturesTestTree :: TestTree+namedCapturesTestTree = localOption (SmallCheckDepth 4) $+ testGroup "NamedCaptures"+ [ formatScanTestTree+ , analyseTokensTestTree+ ]++instance Monad m => Serial m Token++formatScanTestTree :: TestTree+formatScanTestTree =+ testGroup "FormatToken/Scan Properties"+ [ localOption (SmallCheckDepth 4) $+ SC.testProperty "formatTokens == formatTokens0" $+ \tks -> formatTokens tks == formatTokens0 tks+ , localOption (SmallCheckDepth 4) $+ SC.testProperty "scan . formatTokens' idFormatTokenOptions == id" $+ \tks -> all validToken tks ==>+ scan (formatTokens' idFormatTokenOptions tks) == tks+ ]++analyseTokensTestTree :: TestTree+analyseTokensTestTree =+ testGroup "Analysing [Token] Unit Tests"+ [ tc [here|foobar|] []+ , tc [here||] []+ , tc [here|$([0-9]{4})|] []+ , tc [here|${x}()|] [(1,"x")]+ , tc [here|${}()|] []+ , tc [here|${}()${foo}()|] [(2,"foo")]+ , tc [here|${x}(${y()})|] [(1,"x")]+ , tc [here|${x}(${y}())|] [(1,"x"),(2,"y")]+ , tc [here|${a}(${b{}())|] [(1,"a")]+ , tc [here|${y}([0-9]{4})-${m}([0-9]{2})-${d}([0-9]{2})|] [(1,"y"),(2,"m"),(3,"d")]+ , tc [here|@$(@|\{${name}([^{}]+)\})|] [(2,"name")]+ , tc [here|${y}[0-9]{4}|] []+ , tc [here|${}([0-9]{4})|] []+ ]+ where+ tc s al =+ testCase s $ assertEqual "CaptureNames"+ (xnc s)+ (HM.fromList+ [ (CaptureName $ T.pack n,CaptureOrdinal i)+ | (i,n)<-al+ ]+ )++ xnc = either oops fst . extractNamedCaptures+ where+ oops = error "analyseTokensTestTree: unexpected parse failure"+\end{code}+++AddCaptureNames Tests+---------------------++\begin{code}+add_capture_names_tests :: TestTree+add_capture_names_tests = testGroup "AddCaptureNames Tests"+ [ test_add_capture_name "Match String" test_match regex_str_match+ , test_add_capture_name "Matches String" test_matches regex_str_matches+ , test_add_capture_name "Match B.ByteString" test_match $ B.pack <$> regex_str_match+ , test_add_capture_name "Matches B.ByteString" test_matches $ B.pack <$> regex_str_matches+ , test_add_capture_name "Match LBS.ByteString" test_match $ LBS.pack <$> regex_str_match+ , test_add_capture_name "Matches LBS.ByteString" test_matches $ LBS.pack <$> regex_str_matches+ , test_add_capture_name "Match T.Text" test_match $ T.pack <$> regex_str_match+ , test_add_capture_name "Matches T.Text" test_matches $ T.pack <$> regex_str_matches+ , test_add_capture_name "Match LT.Text" test_match $ LT.pack <$> regex_str_match+ , test_add_capture_name "Matches LT.Text" test_matches $ LT.pack <$> regex_str_matches+ , test_add_capture_name "Match (Seq Char)" test_match $ S.fromList <$> regex_str_match+ , test_add_capture_name "Matches (Seq Char)" test_matches $ S.fromList <$> regex_str_matches+ ]++test_matches :: CaptureNames -> Matches a -> Bool+test_matches cnms = all (test_match cnms) . allMatches++test_match :: CaptureNames -> Match a -> Bool+test_match cnms mtch = captureNames mtch == cnms++test_add_capture_name :: Typeable a+ => String+ -> (CaptureNames->a->Bool)+ -> a+ -> TestTree+test_add_capture_name lab tst x = testCase lab $+ assertBool lab $ tst cnms $ addCaptureNames cnms x+ where+ cnms = HM.fromList+ [ (CaptureName "x",1)+ , (CaptureName "y",2)+ ]+\end{code}+++The Miscelaneous Tests+----------------------++\begin{code} misc_tests :: TestTree misc_tests = testGroup "Miscelaneous Tests" [ testGroup "QQ"@@ -347,6 +550,8 @@ , valid_string "preludeMacroSources" preludeMacroSources , valid_macro "preludeMacroSource" preludeMacroSource ]+ -- because HPC can't measure our testing of [re|..|] forms,+ -- we are eliminating them from our enquiries , testGroup "RE" [ valid_res TDFA [ TDFA.re@@ -374,6 +579,8 @@ [ ne_string (presentPreludeMacro pm) $ TDFA.preludeSource pm | pm <- tdfa_prelude_macros ]+ -- because HPC can't measure our testing of [re|..|] forms,+ -- we are eliminating them from our enquiries , valid_res PCRE [ PCRE.re , PCRE.reMS@@ -455,76 +662,4 @@ tdfa_prelude_macros :: [PreludeMacro] tdfa_prelude_macros = [minBound..maxBound]-\end{code}---Testing : FormatToken/Scan Properties----------------------------------------\begin{code}-namedCapturesTestTree :: TestTree-namedCapturesTestTree = localOption (SmallCheckDepth 4) $- testGroup "NamedCaptures"- [ formatScanTestTree- , analyseTokensTestTree- ]-\end{code}--\begin{code}-instance Monad m => Serial m Token-\end{code}---Testing : FormatToken/Scan Properties----------------------------------------\begin{code}-formatScanTestTree :: TestTree-formatScanTestTree =- testGroup "FormatToken/Scan Properties"- [ localOption (SmallCheckDepth 4) $- SC.testProperty "formatTokens == formatTokens0" $- \tks -> formatTokens tks == formatTokens0 tks- , localOption (SmallCheckDepth 4) $- SC.testProperty "scan . formatTokens' idFormatTokenOptions == id" $- \tks -> all validToken tks ==>- scan (formatTokens' idFormatTokenOptions tks) == tks- ]-\end{code}---Testing : Analysing [Token] Unit Tests-----------------------------------------\begin{code}-analyseTokensTestTree :: TestTree-analyseTokensTestTree =- testGroup "Analysing [Token] Unit Tests"- [ tc [here|foobar|] []- , tc [here||] []- , tc [here|$([0-9]{4})|] []- , tc [here|${x}()|] [(1,"x")]- , tc [here|${}()|] []- , tc [here|${}()${foo}()|] [(2,"foo")]- , tc [here|${x}(${y()})|] [(1,"x")]- , tc [here|${x}(${y}())|] [(1,"x"),(2,"y")]- , tc [here|${a}(${b{}())|] [(1,"a")]- , tc [here|${y}([0-9]{4})-${m}([0-9]{2})-${d}([0-9]{2})|] [(1,"y"),(2,"m"),(3,"d")]- , tc [here|@$(@|\{${name}([^{}]+)\})|] [(2,"name")]- , tc [here|${y}[0-9]{4}|] []- , tc [here|${}([0-9]{4})|] []- ]- where- tc s al =- testCase s $ assertEqual "CaptureNames"- (xnc s)- (HM.fromList- [ (CaptureName $ T.pack n,CaptureOrdinal i)- | (i,n)<-al- ]- )-- xnc = either oops fst . extractNamedCaptures- where- oops = error "analyseTokensTestTree: unexpected parse failure" \end{code}
lib/cabal-masters/library-incl.cabal view
@@ -5,6 +5,8 @@ Text.RE.Capture Text.RE.CaptureID Text.RE.Edit+ Text.RE.Internal.AddCaptureNames+ Text.RE.Internal.EscapeREString Text.RE.Internal.NamedCaptures Text.RE.Internal.PreludeMacros Text.RE.Internal.QQ@@ -31,8 +33,5 @@ Text.RE.Tools.Grep Text.RE.Tools.Lex Text.RE.Tools.Sed-- Other-Modules:- Text.RE.Internal.AddCaptureNames %build-depends array bytestring base base-compat containers hashable heredoc regex-base regex-tdfa regex-tdfa-text regex-pcre-builtin template-haskell text time time-locale-compat transformers unordered-containers
lib/mega-regex.cabal view
@@ -1,5 +1,5 @@ Name: regex-Version: 0.3.0.0+Version: 0.5.0.0 Synopsis: Toolkit for regex-base Description: A Regular Expression Toolkit for regex-base with Compile-time checking of RE syntax, data types for@@ -62,7 +62,7 @@ Source-Repository this Type: git Location: https://github.com/iconnect/regex.git- Tag: 0.3.0.0+ Tag: 0.5.0.0 @@ -73,6 +73,8 @@ Text.RE.Capture Text.RE.CaptureID Text.RE.Edit+ Text.RE.Internal.AddCaptureNames+ Text.RE.Internal.EscapeREString Text.RE.Internal.NamedCaptures Text.RE.Internal.PreludeMacros Text.RE.Internal.QQ@@ -100,9 +102,6 @@ Text.RE.Tools.Lex Text.RE.Tools.Sed - Other-Modules:- Text.RE.Internal.AddCaptureNames- Default-Language: Haskell2010 GHC-Options: -Wall@@ -145,7 +144,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -174,7 +173,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -200,7 +199,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -225,7 +224,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -253,7 +252,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , base >= 4 && < 5 , base-compat >= 0.6.0 , bytestring >= 0.10.2.0@@ -278,7 +277,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , base >= 4 && < 5 , base-compat >= 0.6.0 , bytestring >= 0.10.2.0@@ -300,7 +299,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -329,7 +328,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -361,7 +360,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , base >= 4 && < 5 , base-compat >= 0.6.0 , bytestring >= 0.10.2.0@@ -388,7 +387,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , base >= 4 && < 5 , base-compat >= 0.6.0 , bytestring >= 0.10.2.0@@ -415,7 +414,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -452,7 +451,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -490,7 +489,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -533,7 +532,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -578,7 +577,7 @@ -Werror Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0
lib/version.txt view
@@ -1,1 +1,1 @@-0.3.0.0+0.5.0.0
regex-examples.cabal view
@@ -1,5 +1,5 @@ Name: regex-examples-Version: 0.3.0.0+Version: 0.5.0.0 Synopsis: Tutorial, tests and example programs for regex Description: Tutorial, tests and example programs for regex, a Regular Expression Toolkit for regex-base with@@ -63,7 +63,7 @@ Source-Repository this Type: git Location: https://github.com/iconnect/regex.git- Tag: 0.3.0.0+ Tag: 0.5.0.0 @@ -82,7 +82,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -111,7 +111,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -137,7 +137,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -162,7 +162,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -190,7 +190,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , base >= 4 && < 5 , base-compat >= 0.6.0 , bytestring >= 0.10.2.0@@ -215,7 +215,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , base >= 4 && < 5 , base-compat >= 0.6.0 , bytestring >= 0.10.2.0@@ -237,7 +237,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -266,7 +266,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -298,7 +298,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , base >= 4 && < 5 , base-compat >= 0.6.0 , bytestring >= 0.10.2.0@@ -325,7 +325,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , base >= 4 && < 5 , base-compat >= 0.6.0 , bytestring >= 0.10.2.0@@ -352,7 +352,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -389,7 +389,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -427,7 +427,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -470,7 +470,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0@@ -515,7 +515,7 @@ -Wwarn Build-depends:- regex == 0.3.0.0+ regex == 0.5.0.0 , array >= 0.4 , base >= 4 && < 5 , base-compat >= 0.6.0
src/Text/RE/PCRE/ByteString.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -25,7 +26,9 @@ , module Text.RE.PCRE.RE ) where +import Prelude.Compat import qualified Data.ByteString as B+import Data.Typeable import Text.Regex.Base import Text.RE import Text.RE.Internal.AddCaptureNames@@ -46,23 +49,26 @@ (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base polymorphic match operator-(=~) :: ( RegexContext PCRE.Regex B.ByteString a+(=~) :: ( Typeable a+ , RegexContext PCRE.Regex B.ByteString a , RegexMaker PCRE.Regex PCRE.CompOption PCRE.ExecOption String ) => B.ByteString -> RE -> a-(=~) bs rex = match (reRegex rex) bs+(=~) bs rex = addCaptureNames (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m+ , Functor m+ , Typeable a , RegexContext PCRE.Regex B.ByteString a , RegexMaker PCRE.Regex PCRE.CompOption PCRE.ExecOption String ) => B.ByteString -> RE -> m a-(=~~) bs rex = matchM (reRegex rex) bs+(=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE B.ByteString where matchOnce = flip (?=~)
src/Text/RE/PCRE/ByteString/Lazy.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -25,7 +26,9 @@ , module Text.RE.PCRE.RE ) where +import Prelude.Compat import qualified Data.ByteString.Lazy as LBS+import Data.Typeable import Text.Regex.Base import Text.RE import Text.RE.Internal.AddCaptureNames@@ -46,23 +49,26 @@ (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base polymorphic match operator-(=~) :: ( RegexContext PCRE.Regex LBS.ByteString a+(=~) :: ( Typeable a+ , RegexContext PCRE.Regex LBS.ByteString a , RegexMaker PCRE.Regex PCRE.CompOption PCRE.ExecOption String ) => LBS.ByteString -> RE -> a-(=~) bs rex = match (reRegex rex) bs+(=~) bs rex = addCaptureNames (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m+ , Functor m+ , Typeable a , RegexContext PCRE.Regex LBS.ByteString a , RegexMaker PCRE.Regex PCRE.CompOption PCRE.ExecOption String ) => LBS.ByteString -> RE -> m a-(=~~) bs rex = matchM (reRegex rex) bs+(=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE LBS.ByteString where matchOnce = flip (?=~)
src/Text/RE/PCRE/Sequence.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -25,7 +26,9 @@ , module Text.RE.PCRE.RE ) where +import Prelude.Compat import qualified Data.Sequence as S+import Data.Typeable import Text.Regex.Base import Text.RE import Text.RE.Internal.AddCaptureNames@@ -46,23 +49,26 @@ (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base polymorphic match operator-(=~) :: ( RegexContext PCRE.Regex (S.Seq Char) a+(=~) :: ( Typeable a+ , RegexContext PCRE.Regex (S.Seq Char) a , RegexMaker PCRE.Regex PCRE.CompOption PCRE.ExecOption String ) => (S.Seq Char) -> RE -> a-(=~) bs rex = match (reRegex rex) bs+(=~) bs rex = addCaptureNames (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m+ , Functor m+ , Typeable a , RegexContext PCRE.Regex (S.Seq Char) a , RegexMaker PCRE.Regex PCRE.CompOption PCRE.ExecOption String ) => (S.Seq Char) -> RE -> m a-(=~~) bs rex = matchM (reRegex rex) bs+(=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE (S.Seq Char) where matchOnce = flip (?=~)
src/Text/RE/PCRE/String.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -25,7 +26,9 @@ , module Text.RE.PCRE.RE ) where +import Prelude.Compat +import Data.Typeable import Text.Regex.Base import Text.RE import Text.RE.Internal.AddCaptureNames@@ -46,23 +49,26 @@ (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base polymorphic match operator-(=~) :: ( RegexContext PCRE.Regex String a+(=~) :: ( Typeable a+ , RegexContext PCRE.Regex String a , RegexMaker PCRE.Regex PCRE.CompOption PCRE.ExecOption String ) => String -> RE -> a-(=~) bs rex = match (reRegex rex) bs+(=~) bs rex = addCaptureNames (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m+ , Functor m+ , Typeable a , RegexContext PCRE.Regex String a , RegexMaker PCRE.Regex PCRE.CompOption PCRE.ExecOption String ) => String -> RE -> m a-(=~~) bs rex = matchM (reRegex rex) bs+(=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE String where matchOnce = flip (?=~)
src/Text/RE/TDFA/ByteString.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -25,7 +26,9 @@ , module Text.RE.TDFA.RE ) where +import Prelude.Compat import qualified Data.ByteString as B+import Data.Typeable import Text.Regex.Base import Text.RE import Text.RE.Internal.AddCaptureNames@@ -46,23 +49,26 @@ (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base polymorphic match operator-(=~) :: ( RegexContext TDFA.Regex B.ByteString a+(=~) :: ( Typeable a+ , RegexContext TDFA.Regex B.ByteString a , RegexMaker TDFA.Regex TDFA.CompOption TDFA.ExecOption String ) => B.ByteString -> RE -> a-(=~) bs rex = match (reRegex rex) bs+(=~) bs rex = addCaptureNames (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m+ , Functor m+ , Typeable a , RegexContext TDFA.Regex B.ByteString a , RegexMaker TDFA.Regex TDFA.CompOption TDFA.ExecOption String ) => B.ByteString -> RE -> m a-(=~~) bs rex = matchM (reRegex rex) bs+(=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE B.ByteString where matchOnce = flip (?=~)
src/Text/RE/TDFA/ByteString/Lazy.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -25,7 +26,9 @@ , module Text.RE.TDFA.RE ) where +import Prelude.Compat import qualified Data.ByteString.Lazy.Char8 as LBS+import Data.Typeable import Text.Regex.Base import Text.RE import Text.RE.Internal.AddCaptureNames@@ -46,23 +49,26 @@ (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base polymorphic match operator-(=~) :: ( RegexContext TDFA.Regex LBS.ByteString a+(=~) :: ( Typeable a+ , RegexContext TDFA.Regex LBS.ByteString a , RegexMaker TDFA.Regex TDFA.CompOption TDFA.ExecOption String ) => LBS.ByteString -> RE -> a-(=~) bs rex = match (reRegex rex) bs+(=~) bs rex = addCaptureNames (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m+ , Functor m+ , Typeable a , RegexContext TDFA.Regex LBS.ByteString a , RegexMaker TDFA.Regex TDFA.CompOption TDFA.ExecOption String ) => LBS.ByteString -> RE -> m a-(=~~) bs rex = matchM (reRegex rex) bs+(=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE LBS.ByteString where matchOnce = flip (?=~)
src/Text/RE/TDFA/Sequence.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -25,7 +26,9 @@ , module Text.RE.TDFA.RE ) where +import Prelude.Compat import qualified Data.Sequence as S+import Data.Typeable import Text.Regex.Base import Text.RE import Text.RE.Internal.AddCaptureNames@@ -46,23 +49,26 @@ (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base polymorphic match operator-(=~) :: ( RegexContext TDFA.Regex (S.Seq Char) a+(=~) :: ( Typeable a+ , RegexContext TDFA.Regex (S.Seq Char) a , RegexMaker TDFA.Regex TDFA.CompOption TDFA.ExecOption String ) => (S.Seq Char) -> RE -> a-(=~) bs rex = match (reRegex rex) bs+(=~) bs rex = addCaptureNames (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m+ , Functor m+ , Typeable a , RegexContext TDFA.Regex (S.Seq Char) a , RegexMaker TDFA.Regex TDFA.CompOption TDFA.ExecOption String ) => (S.Seq Char) -> RE -> m a-(=~~) bs rex = matchM (reRegex rex) bs+(=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE (S.Seq Char) where matchOnce = flip (?=~)
src/Text/RE/TDFA/String.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -25,7 +26,9 @@ , module Text.RE.TDFA.RE ) where +import Prelude.Compat +import Data.Typeable import Text.Regex.Base import Text.RE import Text.RE.Internal.AddCaptureNames@@ -46,23 +49,26 @@ (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base polymorphic match operator-(=~) :: ( RegexContext TDFA.Regex String a+(=~) :: ( Typeable a+ , RegexContext TDFA.Regex String a , RegexMaker TDFA.Regex TDFA.CompOption TDFA.ExecOption String ) => String -> RE -> a-(=~) bs rex = match (reRegex rex) bs+(=~) bs rex = addCaptureNames (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m+ , Functor m+ , Typeable a , RegexContext TDFA.Regex String a , RegexMaker TDFA.Regex TDFA.CompOption TDFA.ExecOption String ) => String -> RE -> m a-(=~~) bs rex = matchM (reRegex rex) bs+(=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE String where matchOnce = flip (?=~)
src/Text/RE/TDFA/Text.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -25,7 +26,9 @@ , module Text.RE.TDFA.RE ) where +import Prelude.Compat import qualified Data.Text as T+import Data.Typeable import Text.Regex.Base import Text.RE import Text.RE.Internal.AddCaptureNames@@ -46,23 +49,26 @@ (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base polymorphic match operator-(=~) :: ( RegexContext TDFA.Regex T.Text a+(=~) :: ( Typeable a+ , RegexContext TDFA.Regex T.Text a , RegexMaker TDFA.Regex TDFA.CompOption TDFA.ExecOption String ) => T.Text -> RE -> a-(=~) bs rex = match (reRegex rex) bs+(=~) bs rex = addCaptureNames (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m+ , Functor m+ , Typeable a , RegexContext TDFA.Regex T.Text a , RegexMaker TDFA.Regex TDFA.CompOption TDFA.ExecOption String ) => T.Text -> RE -> m a-(=~~) bs rex = matchM (reRegex rex) bs+(=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE T.Text where matchOnce = flip (?=~)
src/Text/RE/TDFA/Text/Lazy.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -25,7 +26,9 @@ , module Text.RE.TDFA.RE ) where +import Prelude.Compat import qualified Data.Text.Lazy as TL+import Data.Typeable import Text.Regex.Base import Text.RE import Text.RE.Internal.AddCaptureNames@@ -46,23 +49,26 @@ (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base polymorphic match operator-(=~) :: ( RegexContext TDFA.Regex TL.Text a+(=~) :: ( Typeable a+ , RegexContext TDFA.Regex TL.Text a , RegexMaker TDFA.Regex TDFA.CompOption TDFA.ExecOption String ) => TL.Text -> RE -> a-(=~) bs rex = match (reRegex rex) bs+(=~) bs rex = addCaptureNames (reCaptureNames rex) $ match (reRegex rex) bs -- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m+ , Functor m+ , Typeable a , RegexContext TDFA.Regex TL.Text a , RegexMaker TDFA.Regex TDFA.CompOption TDFA.ExecOption String ) => TL.Text -> RE -> m a-(=~~) bs rex = matchM (reRegex rex) bs+(=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE TL.Text where matchOnce = flip (?=~)