regex 0.3.0.0 → 0.5.0.0
raw patch · 19 files changed
+221/−53 lines, 19 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.RE.Internal.AddCaptureNames: addCaptureNames :: Typeable a => CaptureNames -> a -> a
+ Text.RE.Internal.AddCaptureNames: addCaptureNamesToMatch :: CaptureNames -> Match a -> Match a
+ Text.RE.Internal.AddCaptureNames: addCaptureNamesToMatches :: CaptureNames -> Matches a -> Matches a
+ Text.RE.Internal.EscapeREString: escapeREString :: String -> String
+ Text.RE.Internal.EscapeREString: isMetaChar :: Char -> Bool
+ Text.RE.PCRE.RE: escape :: (String -> String) -> String -> RE
+ Text.RE.PCRE.RE: escapeREString :: String -> String
+ Text.RE.TDFA.RE: escape :: (String -> String) -> String -> RE
+ Text.RE.TDFA.RE: escapeREString :: String -> String
- Text.RE.PCRE.ByteString: (=~) :: (RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> a
+ Text.RE.PCRE.ByteString: (=~) :: (Typeable a, RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> a
- Text.RE.PCRE.ByteString: (=~~) :: (Monad m, RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> m a
+ Text.RE.PCRE.ByteString: (=~~) :: (Monad m, Functor m, Typeable a, RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> m a
- Text.RE.PCRE.ByteString.Lazy: (=~) :: (RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> a
+ Text.RE.PCRE.ByteString.Lazy: (=~) :: (Typeable a, RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> a
- Text.RE.PCRE.ByteString.Lazy: (=~~) :: (Monad m, RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> m a
+ Text.RE.PCRE.ByteString.Lazy: (=~~) :: (Monad m, Functor m, Typeable a, RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> m a
- Text.RE.PCRE.Sequence: (=~) :: (RegexContext Regex (Seq Char) a, RegexMaker Regex CompOption ExecOption String) => (Seq Char) -> RE -> a
+ Text.RE.PCRE.Sequence: (=~) :: (Typeable a, RegexContext Regex (Seq Char) a, RegexMaker Regex CompOption ExecOption String) => (Seq Char) -> RE -> a
- Text.RE.PCRE.Sequence: (=~~) :: (Monad m, RegexContext Regex (Seq Char) a, RegexMaker Regex CompOption ExecOption String) => (Seq Char) -> RE -> m a
+ Text.RE.PCRE.Sequence: (=~~) :: (Monad m, Functor m, Typeable a, RegexContext Regex (Seq Char) a, RegexMaker Regex CompOption ExecOption String) => (Seq Char) -> RE -> m a
- Text.RE.PCRE.String: (=~) :: (RegexContext Regex String a, RegexMaker Regex CompOption ExecOption String) => String -> RE -> a
+ Text.RE.PCRE.String: (=~) :: (Typeable a, RegexContext Regex String a, RegexMaker Regex CompOption ExecOption String) => String -> RE -> a
- Text.RE.PCRE.String: (=~~) :: (Monad m, RegexContext Regex String a, RegexMaker Regex CompOption ExecOption String) => String -> RE -> m a
+ Text.RE.PCRE.String: (=~~) :: (Monad m, Functor m, Typeable a, RegexContext Regex String a, RegexMaker Regex CompOption ExecOption String) => String -> RE -> m a
- Text.RE.TDFA.ByteString: (=~) :: (RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> a
+ Text.RE.TDFA.ByteString: (=~) :: (Typeable a, RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> a
- Text.RE.TDFA.ByteString: (=~~) :: (Monad m, RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> m a
+ Text.RE.TDFA.ByteString: (=~~) :: (Monad m, Functor m, Typeable a, RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> m a
- Text.RE.TDFA.ByteString.Lazy: (=~) :: (RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> a
+ Text.RE.TDFA.ByteString.Lazy: (=~) :: (Typeable a, RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> a
- Text.RE.TDFA.ByteString.Lazy: (=~~) :: (Monad m, RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> m a
+ Text.RE.TDFA.ByteString.Lazy: (=~~) :: (Monad m, Functor m, Typeable a, RegexContext Regex ByteString a, RegexMaker Regex CompOption ExecOption String) => ByteString -> RE -> m a
- Text.RE.TDFA.Sequence: (=~) :: (RegexContext Regex (Seq Char) a, RegexMaker Regex CompOption ExecOption String) => (Seq Char) -> RE -> a
+ Text.RE.TDFA.Sequence: (=~) :: (Typeable a, RegexContext Regex (Seq Char) a, RegexMaker Regex CompOption ExecOption String) => (Seq Char) -> RE -> a
- Text.RE.TDFA.Sequence: (=~~) :: (Monad m, RegexContext Regex (Seq Char) a, RegexMaker Regex CompOption ExecOption String) => (Seq Char) -> RE -> m a
+ Text.RE.TDFA.Sequence: (=~~) :: (Monad m, Functor m, Typeable a, RegexContext Regex (Seq Char) a, RegexMaker Regex CompOption ExecOption String) => (Seq Char) -> RE -> m a
- Text.RE.TDFA.String: (=~) :: (RegexContext Regex String a, RegexMaker Regex CompOption ExecOption String) => String -> RE -> a
+ Text.RE.TDFA.String: (=~) :: (Typeable a, RegexContext Regex String a, RegexMaker Regex CompOption ExecOption String) => String -> RE -> a
- Text.RE.TDFA.String: (=~~) :: (Monad m, RegexContext Regex String a, RegexMaker Regex CompOption ExecOption String) => String -> RE -> m a
+ Text.RE.TDFA.String: (=~~) :: (Monad m, Functor m, Typeable a, RegexContext Regex String a, RegexMaker Regex CompOption ExecOption String) => String -> RE -> m a
- Text.RE.TDFA.Text: (=~) :: (RegexContext Regex Text a, RegexMaker Regex CompOption ExecOption String) => Text -> RE -> a
+ Text.RE.TDFA.Text: (=~) :: (Typeable a, RegexContext Regex Text a, RegexMaker Regex CompOption ExecOption String) => Text -> RE -> a
- Text.RE.TDFA.Text: (=~~) :: (Monad m, RegexContext Regex Text a, RegexMaker Regex CompOption ExecOption String) => Text -> RE -> m a
+ Text.RE.TDFA.Text: (=~~) :: (Monad m, Functor m, Typeable a, RegexContext Regex Text a, RegexMaker Regex CompOption ExecOption String) => Text -> RE -> m a
- Text.RE.TDFA.Text.Lazy: (=~) :: (RegexContext Regex Text a, RegexMaker Regex CompOption ExecOption String) => Text -> RE -> a
+ Text.RE.TDFA.Text.Lazy: (=~) :: (Typeable a, RegexContext Regex Text a, RegexMaker Regex CompOption ExecOption String) => Text -> RE -> a
- Text.RE.TDFA.Text.Lazy: (=~~) :: (Monad m, RegexContext Regex Text a, RegexMaker Regex CompOption ExecOption String) => Text -> RE -> m a
+ Text.RE.TDFA.Text.Lazy: (=~~) :: (Monad m, Functor m, Typeable a, RegexContext Regex Text a, RegexMaker Regex CompOption ExecOption String) => Text -> RE -> m a
Files
- README.markdown +1/−1
- Text/RE/Capture.lhs +4/−2
- Text/RE/Internal/AddCaptureNames.hs +58/−0
- Text/RE/Internal/EscapeREString.hs +25/−0
- Text/RE/PCRE/ByteString.hs +9/−3
- Text/RE/PCRE/ByteString/Lazy.hs +9/−3
- Text/RE/PCRE/RE.hs +6/−0
- Text/RE/PCRE/Sequence.hs +9/−3
- Text/RE/PCRE/String.hs +9/−3
- Text/RE/Replace.lhs +18/−15
- Text/RE/TDFA/ByteString.hs +9/−3
- Text/RE/TDFA/ByteString/Lazy.hs +9/−3
- Text/RE/TDFA/RE.hs +6/−0
- Text/RE/TDFA/Sequence.hs +9/−3
- Text/RE/TDFA/String.hs +9/−3
- Text/RE/TDFA/Text.hs +9/−3
- Text/RE/TDFA/Text/Lazy.hs +9/−3
- changelog +9/−0
- regex.cabal +4/−5
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)
Text/RE/Capture.lhs view
@@ -3,6 +3,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE DeriveDataTypeable #-} \end{code} \begin{code}@@ -40,6 +41,7 @@ \begin{code} import Data.Array import Data.Maybe+import Data.Typeable import Text.Regex.Base import Text.RE.CaptureID @@ -56,7 +58,7 @@ { matchesSource :: !a -- ^ the source text being matched , allMatches :: ![Match a] -- ^ all captures found, left to right }- deriving (Show,Eq)+ deriving (Show,Eq,Typeable) \end{code} \begin{code}@@ -74,7 +76,7 @@ -- text matched by the -- whole RE }- deriving (Show,Eq)+ deriving (Show,Eq,Typeable) \end{code} \begin{code}
Text/RE/Internal/AddCaptureNames.hs view
@@ -1,11 +1,69 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE ExistentialQuantification #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE OverloadedStrings #-}+ module Text.RE.Internal.AddCaptureNames where +import qualified Data.ByteString.Lazy.Char8 as LBS+import qualified Data.ByteString.Char8 as B+import Data.Dynamic+import Data.Maybe+import qualified Data.Sequence as S+import qualified Data.Text as T+import qualified Data.Text.Lazy as TL+import Prelude.Compat import Text.RE+import Unsafe.Coerce +-- | a convenience function used by the API modules to insert+-- capture names extracted from the parsed RE into the (*=~) result addCaptureNamesToMatches :: CaptureNames -> Matches a -> Matches a addCaptureNamesToMatches cnms mtchs = mtchs { allMatches = map (addCaptureNamesToMatch cnms) $ allMatches mtchs } +-- | a convenience function used by the API modules to insert+-- capture names extracted from the parsed RE into the (?=~) result addCaptureNamesToMatch :: CaptureNames -> Match a -> Match a addCaptureNamesToMatch cnms mtch = mtch { captureNames = cnms }++-- | a hairy dynamically-typed function used with the legacy (=~) and (=~~)+-- to see if it can/should add the capture names extracted from the RE+-- into the polymorphic result of the operator (it does for any Match+-- or Matches type, provided it is parameterised over a recognised type).+-- The test suite is all over this one, testing all of these cases.+addCaptureNames :: Typeable a => CaptureNames -> a -> a+addCaptureNames cnms x = fromMaybe x $ listToMaybe $ catMaybes+ [ test_match x ( proxy :: String )+ , test_matches x ( proxy :: String )+ , test_match x ( proxy :: B.ByteString )+ , test_matches x ( proxy :: B.ByteString )+ , test_match x ( proxy :: LBS.ByteString )+ , test_matches x ( proxy :: LBS.ByteString )+ , test_match x ( proxy :: T.Text )+ , test_matches x ( proxy :: T.Text )+ , test_match x ( proxy :: TL.Text )+ , test_matches x ( proxy :: TL.Text )+ , test_match x ( proxy :: S.Seq Char )+ , test_matches x ( proxy :: S.Seq Char )+ ]+ where+ test_match :: Typeable t => r -> t -> Maybe r+ test_match r t = f r t $ addCaptureNamesToMatch cnms <$> fromDynamic dyn+ where+ f :: r' -> t' -> Maybe (Match t') -> Maybe r'+ f _ _ = unsafeCoerce++ test_matches :: Typeable t => r -> t -> Maybe r+ test_matches r t = f r t $ addCaptureNamesToMatches cnms <$> fromDynamic dyn+ where+ f :: r' -> t' -> Maybe (Matches t') -> Maybe r'+ f _ _ = unsafeCoerce++ dyn :: Dynamic+ dyn = toDyn x++ proxy :: a+ proxy = error "addCaptureNames"
+ Text/RE/Internal/EscapeREString.hs view
@@ -0,0 +1,25 @@+module Text.RE.Internal.EscapeREString where++escapeREString :: String -> String+escapeREString = foldr esc []+ where+ esc c t | isMetaChar c = '\\' : c : t+ | otherwise = c : t++isMetaChar :: Char -> Bool+isMetaChar c = case c of+ '^' -> True+ '\\' -> True+ '.' -> True+ '|' -> True+ '*' -> True+ '?' -> True+ '+' -> True+ '(' -> True+ ')' -> True+ '[' -> True+ ']' -> True+ '{' -> True+ '}' -> True+ '$' -> True+ _ -> False
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 (?=~)
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 (?=~)
Text/RE/PCRE/RE.hs view
@@ -42,6 +42,8 @@ , defaultOptions , unpackSimpleRegexOptions , compileRegex+ , escape+ , escapeREString ) where import Data.Bits@@ -50,6 +52,7 @@ import Language.Haskell.TH.Quote import Prelude.Compat import Text.RE+import Text.RE.Internal.EscapeREString import Text.RE.Internal.NamedCaptures import Text.RE.Internal.PreludeMacros import Text.RE.Internal.QQ@@ -243,3 +246,6 @@ preludeSource :: PreludeMacro -> String preludeSource = preludeMacroSource PCRE++escape :: (String->String) -> String -> RE+escape f = unsafeCompileRegex () . f . escapeREString
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 (?=~)
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 (?=~)
Text/RE/Replace.lhs view
@@ -44,6 +44,7 @@ import Text.RE.Capture import Text.RE.CaptureID import Text.RE.Options+import Text.Read import Text.Regex.TDFA import Text.Regex.TDFA.Text() import Text.Regex.TDFA.Text.Lazy()@@ -402,29 +403,31 @@ \begin{code} parseTemplateE' :: ( Replace a- , RegexContext Regex a (Matches a)- , RegexMaker Regex CompOption ExecOption String- )- => (a->String)- -> a- -> Match a- -> Location- -> Capture a- -> Maybe a+ , RegexContext Regex a (Matches a)+ , RegexMaker Regex CompOption ExecOption String+ )+ => (a->String)+ -> a+ -> Match a+ -> Location+ -> Capture a+ -> Maybe a parseTemplateE' unpack tpl mtch _ _ = Just $ replaceAllCaptures TOP phi $- tpl $=~ [here|\$(\$|[0-9]+|\{([^{}]+)\})|]+ tpl $=~ [here|\$(\$|[0-9]|\{([^{}]+)\})|] where- phi t_mtch _ _ = case t_mtch !$? c2 of- Just cap -> this $ IsCaptureName $ CaptureName txt+ phi t_mtch _ _ = case t_mtch !$? c2 of+ Just cap -> case readMaybe stg of+ Nothing -> this $ IsCaptureName $ CaptureName $ T.pack stg+ Just cn -> this $ IsCaptureOrdinal $ CaptureOrdinal cn where- txt = T.pack $ unpack $ capturedText cap+ stg = unpack $ capturedText cap Nothing -> case s == "$" of True -> Just t False -> this $ IsCaptureOrdinal $ CaptureOrdinal $ read s where- s = unpack t- t = capturedText $ capture c1 t_mtch+ s = unpack t+ t = capturedText $ capture c1 t_mtch this cid = capturedText <$> mtch !$? cid
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 (?=~)
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 (?=~)
Text/RE/TDFA/RE.hs view
@@ -42,6 +42,8 @@ , preludeSource , unpackSimpleRegexOptions , compileRegex+ , escape+ , escapeREString ) where import Data.Functor.Identity@@ -49,6 +51,7 @@ import Language.Haskell.TH.Quote import Prelude.Compat import Text.RE+import Text.RE.Internal.EscapeREString import Text.RE.Internal.NamedCaptures import Text.RE.Internal.PreludeMacros import Text.RE.Internal.QQ@@ -239,3 +242,6 @@ preludeSource :: PreludeMacro -> String preludeSource = preludeMacroSource TDFA++escape :: (String->String) -> String -> RE+escape f = unsafeCompileRegex () . f . escapeREString
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 (?=~)
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 (?=~)
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 (?=~)
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 (?=~)
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
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@@ -31,7 +31,7 @@ Source-Repository this Type: git Location: https://github.com/iconnect/regex.git- Tag: 0.3.0.0+ Tag: 0.5.0.0 @@ -42,6 +42,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@@ -68,9 +70,6 @@ Text.RE.Tools.Grep Text.RE.Tools.Lex Text.RE.Tools.Sed-- Other-Modules:- Text.RE.Internal.AddCaptureNames Default-Language: Haskell2010 GHC-Options: