packages feed

regex 0.2.0.4 → 0.3.0.0

raw patch · 29 files changed

+566/−297 lines, 29 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Text.RE: Block :: Mode
- Text.RE: CID_name :: CaptureName -> CaptureID
- Text.RE: CID_ordinal :: CaptureOrdinal -> CaptureID
- Text.RE: EDIT_fun :: Context -> (LineNo -> Match s -> Location -> Capture s -> m (Maybe s)) -> Edit m s
- Text.RE: EDIT_gen :: (LineNo -> Matches s -> m (LineEdit s)) -> Edit m s
- Text.RE: EDIT_phi :: (Phi s) -> Edit m s
- Text.RE: EDIT_tpl :: s -> Edit m s
- Text.RE: Phi :: Context -> (Location -> a -> a) -> Phi a
- Text.RE: Replace_ :: (a -> Int) -> ((a -> a) -> Capture a -> a) -> Replace_ a
- Text.RE: Simple :: Mode
- Text.RE: [_MacroID] :: MacroID -> String
- Text.RE: [_ln_matches] :: Line -> Matches ByteString
- Text.RE: [_ln_no] :: Line -> LineNo
- Text.RE: [_loc_capture] :: Location -> CaptureOrdinal
- Text.RE: [_loc_match] :: Location -> Int
- Text.RE: [_options_comp] :: Options_ r c e -> !c
- Text.RE: [_options_exec] :: Options_ r c e -> !e
- Text.RE: [_options_macs] :: Options_ r c e -> !(Macros r)
- Text.RE: [_options_mode] :: Options_ r c e -> !Mode
- Text.RE: [_phi_context] :: Phi a -> Context
- Text.RE: [_phi_phi] :: Phi a -> Location -> a -> a
- Text.RE: [_r_length] :: Replace_ a -> a -> Int
- Text.RE: [_r_subst] :: Replace_ a -> (a -> a) -> Capture a -> a
- Text.RE: appendNewline :: Replace a => a -> a
- Text.RE: data Mode
- Text.RE: data Phi a
- Text.RE: data Replace_ a
- Text.RE: detextify :: Replace a => Text -> a
- Text.RE: length_ :: Replace a => a -> Int
- Text.RE: pack_ :: Replace a => String -> a
- Text.RE: parse_tpl :: Replace a => a -> Match a -> Location -> Capture a -> Maybe a
- Text.RE: replaceAllCaptures' :: Replace a => Context -> (Match a -> Location -> Capture a -> Maybe a) -> Matches a -> a
- Text.RE: replaceCaptures' :: Replace a => Context -> (Match a -> Location -> Capture a -> Maybe a) -> Match a -> a
- Text.RE: replace_ :: Replace a => Replace_ a
- Text.RE: subst :: Replace a => (a -> a) -> Capture a -> a
- Text.RE: textify :: Replace a => a -> Text
- Text.RE: unpack_ :: Replace a => a -> String
- Text.RE.CaptureID: CID_name :: CaptureName -> CaptureID
- Text.RE.CaptureID: CID_ordinal :: CaptureOrdinal -> CaptureID
- Text.RE.Edit: EDIT_fun :: Context -> (LineNo -> Match s -> Location -> Capture s -> m (Maybe s)) -> Edit m s
- Text.RE.Edit: EDIT_gen :: (LineNo -> Matches s -> m (LineEdit s)) -> Edit m s
- Text.RE.Edit: EDIT_phi :: (Phi s) -> Edit m s
- Text.RE.Edit: EDIT_tpl :: s -> Edit m s
- Text.RE.Options: Block :: Mode
- Text.RE.Options: Simple :: Mode
- Text.RE.Options: [_MacroID] :: MacroID -> String
- Text.RE.Options: [_options_comp] :: Options_ r c e -> !c
- Text.RE.Options: [_options_exec] :: Options_ r c e -> !e
- Text.RE.Options: [_options_macs] :: Options_ r c e -> !(Macros r)
- Text.RE.Options: [_options_mode] :: Options_ r c e -> !Mode
- Text.RE.Options: data Mode
- Text.RE.Options: instance GHC.Classes.Eq Text.RE.Options.Mode
- Text.RE.Options: instance GHC.Classes.Ord Text.RE.Options.Mode
- Text.RE.Options: instance GHC.Enum.Bounded Text.RE.Options.Mode
- Text.RE.Options: instance GHC.Enum.Enum Text.RE.Options.Mode
- Text.RE.Options: instance GHC.Show.Show Text.RE.Options.Mode
- Text.RE.PCRE.RE: instance Text.RE.Options.IsOption Text.RE.Options.Mode Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.Replace: Phi :: Context -> (Location -> a -> a) -> Phi a
- Text.RE.Replace: Replace_ :: (a -> Int) -> ((a -> a) -> Capture a -> a) -> Replace_ a
- Text.RE.Replace: [_loc_capture] :: Location -> CaptureOrdinal
- Text.RE.Replace: [_loc_match] :: Location -> Int
- Text.RE.Replace: [_phi_context] :: Phi a -> Context
- Text.RE.Replace: [_phi_phi] :: Phi a -> Location -> a -> a
- Text.RE.Replace: [_r_length] :: Replace_ a -> a -> Int
- Text.RE.Replace: [_r_subst] :: Replace_ a -> (a -> a) -> Capture a -> a
- Text.RE.Replace: appendNewline :: Replace a => a -> a
- Text.RE.Replace: data Phi a
- Text.RE.Replace: data Replace_ a
- Text.RE.Replace: detextify :: Replace a => Text -> a
- Text.RE.Replace: length_ :: Replace a => a -> Int
- Text.RE.Replace: pack_ :: Replace a => String -> a
- Text.RE.Replace: parse_tpl :: Replace a => a -> Match a -> Location -> Capture a -> Maybe a
- Text.RE.Replace: replaceAllCaptures' :: Replace a => Context -> (Match a -> Location -> Capture a -> Maybe a) -> Matches a -> a
- Text.RE.Replace: replaceCaptures' :: Replace a => Context -> (Match a -> Location -> Capture a -> Maybe a) -> Match a -> a
- Text.RE.Replace: replace_ :: Replace a => Replace_ a
- Text.RE.Replace: subst :: Replace a => (a -> a) -> Capture a -> a
- Text.RE.Replace: textify :: Replace a => a -> Text
- Text.RE.Replace: unpack_ :: Replace a => a -> String
- Text.RE.TDFA.RE: instance Text.RE.Options.IsOption Text.RE.Options.Mode Text.RE.TDFA.RE.RE Text.Regex.TDFA.Common.CompOption Text.Regex.TDFA.Common.ExecOption
- Text.RE.TestBench: [_MacroID] :: MacroID -> String
- Text.RE.Tools.Grep: [_ln_matches] :: Line -> Matches ByteString
- Text.RE.Tools.Grep: [_ln_no] :: Line -> LineNo
+ Text.RE: Function :: Context -> (LineNo -> Match s -> Location -> Capture s -> m (Maybe s)) -> Edit m s
+ Text.RE: IsCaptureName :: CaptureName -> CaptureID
+ Text.RE: IsCaptureOrdinal :: CaptureOrdinal -> CaptureID
+ Text.RE: LineEdit :: (LineNo -> Matches s -> m (LineEdit s)) -> Edit m s
+ Text.RE: ReplaceMethods :: (a -> Int) -> ((a -> a) -> Capture a -> a) -> ReplaceMethods a
+ Text.RE: Template :: s -> Edit m s
+ Text.RE: [getLineMatches] :: Line -> Matches ByteString
+ Text.RE: [getLineNumber] :: Line -> LineNo
+ Text.RE: [getMacroID] :: MacroID -> String
+ Text.RE: [locationCapture] :: Location -> CaptureOrdinal
+ Text.RE: [locationMatch] :: Location -> Int
+ Text.RE: [methodLength] :: ReplaceMethods a -> a -> Int
+ Text.RE: [methodSubst] :: ReplaceMethods a -> (a -> a) -> Capture a -> a
+ Text.RE: [optionsComp] :: Options_ r c e -> !c
+ Text.RE: [optionsExec] :: Options_ r c e -> !e
+ Text.RE: [optionsMacs] :: Options_ r c e -> !(Macros r)
+ Text.RE: appendNewlineE :: Replace a => a -> a
+ Text.RE: data ReplaceMethods a
+ Text.RE: detextifyE :: Replace a => Text -> a
+ Text.RE: lengthE :: Replace a => a -> Int
+ Text.RE: packE :: Replace a => String -> a
+ Text.RE: parseTemplateE :: Replace a => a -> Match a -> Location -> Capture a -> Maybe a
+ Text.RE: replaceMethods :: Replace a => ReplaceMethods a
+ Text.RE: substE :: Replace a => (a -> a) -> Capture a -> a
+ Text.RE: textifyE :: Replace a => a -> Text
+ Text.RE: unpackE :: Replace a => a -> String
+ Text.RE.CaptureID: IsCaptureName :: CaptureName -> CaptureID
+ Text.RE.CaptureID: IsCaptureOrdinal :: CaptureOrdinal -> CaptureID
+ Text.RE.Edit: Function :: Context -> (LineNo -> Match s -> Location -> Capture s -> m (Maybe s)) -> Edit m s
+ Text.RE.Edit: LineEdit :: (LineNo -> Matches s -> m (LineEdit s)) -> Edit m s
+ Text.RE.Edit: Template :: s -> Edit m s
+ Text.RE.Options: [getMacroID] :: MacroID -> String
+ Text.RE.Options: [optionsComp] :: Options_ r c e -> !c
+ Text.RE.Options: [optionsExec] :: Options_ r c e -> !e
+ Text.RE.Options: [optionsMacs] :: Options_ r c e -> !(Macros r)
+ Text.RE.Replace: ReplaceMethods :: (a -> Int) -> ((a -> a) -> Capture a -> a) -> ReplaceMethods a
+ Text.RE.Replace: [locationCapture] :: Location -> CaptureOrdinal
+ Text.RE.Replace: [locationMatch] :: Location -> Int
+ Text.RE.Replace: [methodLength] :: ReplaceMethods a -> a -> Int
+ Text.RE.Replace: [methodSubst] :: ReplaceMethods a -> (a -> a) -> Capture a -> a
+ Text.RE.Replace: appendNewlineE :: Replace a => a -> a
+ Text.RE.Replace: data ReplaceMethods a
+ Text.RE.Replace: detextifyE :: Replace a => Text -> a
+ Text.RE.Replace: lengthE :: Replace a => a -> Int
+ Text.RE.Replace: packE :: Replace a => String -> a
+ Text.RE.Replace: parseTemplateE :: Replace a => a -> Match a -> Location -> Capture a -> Maybe a
+ Text.RE.Replace: replaceMethods :: Replace a => ReplaceMethods a
+ Text.RE.Replace: substE :: Replace a => (a -> a) -> Capture a -> a
+ Text.RE.Replace: textifyE :: Replace a => a -> Text
+ Text.RE.Replace: unpackE :: Replace a => a -> String
+ Text.RE.TestBench: [getMacroID] :: MacroID -> String
+ Text.RE.Tools.Grep: [getLineMatches] :: Line -> Matches ByteString
+ Text.RE.Tools.Grep: [getLineNumber] :: Line -> LineNo
- Text.RE: Options :: !Mode -> !(Macros r) -> !c -> !e -> Options_ r c e
+ Text.RE: Options :: !(Macros r) -> !c -> !e -> Options_ r c e
- Text.RE: class (Extract a, Monoid a) => Replace a where textify = pack . unpack_ detextify = pack_ . unpack appendNewline = (<> pack_ "\n") subst f m@(Capture {..}) = capturePrefix m <> f capturedText <> captureSuffix m
+ Text.RE: class (Extract a, Monoid a) => Replace a where textifyE = pack . unpackE detextifyE = packE . unpack appendNewlineE = (<> packE "\n") substE f m@(Capture {..}) = capturePrefix m <> f capturedText <> captureSuffix m
- Text.RE: expandMacros :: (r -> String) -> Mode -> Macros r -> String -> String
+ Text.RE: expandMacros :: (r -> String) -> Macros r -> String -> String
- Text.RE: replaceAllCaptures :: Replace a => Phi a -> Matches a -> a
+ Text.RE: replaceAllCaptures :: Replace a => Context -> (Match a -> Location -> Capture a -> Maybe a) -> Matches a -> a
- Text.RE: replaceAllCapturesM :: (Extract a, Monad m) => Replace_ a -> Context -> (Match a -> Location -> Capture a -> m (Maybe a)) -> Matches a -> m a
+ Text.RE: replaceAllCapturesM :: (Extract a, Monad m) => ReplaceMethods a -> Context -> (Match a -> Location -> Capture a -> m (Maybe a)) -> Matches a -> m a
- Text.RE: replaceAllCaptures_ :: Extract a => Replace_ a -> Context -> (Match a -> Location -> Capture a -> Maybe a) -> Matches a -> a
+ Text.RE: replaceAllCaptures_ :: Extract a => ReplaceMethods a -> Context -> (Match a -> Location -> Capture a -> Maybe a) -> Matches a -> a
- Text.RE: replaceCaptures :: Replace a => Phi a -> Match a -> a
+ Text.RE: replaceCaptures :: Replace a => Context -> (Match a -> Location -> Capture a -> Maybe a) -> Match a -> a
- Text.RE: replaceCapturesM :: (Monad m, Extract a) => Replace_ a -> Context -> (Match a -> Location -> Capture a -> m (Maybe a)) -> Match a -> m a
+ Text.RE: replaceCapturesM :: (Monad m, Extract a) => ReplaceMethods a -> Context -> (Match a -> Location -> Capture a -> m (Maybe a)) -> Match a -> m a
- Text.RE: replaceCaptures_ :: Extract a => Replace_ a -> Context -> (Match a -> Location -> Capture a -> Maybe a) -> Match a -> a
+ Text.RE: replaceCaptures_ :: Extract a => ReplaceMethods a -> Context -> (Match a -> Location -> Capture a -> Maybe a) -> Match a -> a
- Text.RE.Options: Options :: !Mode -> !(Macros r) -> !c -> !e -> Options_ r c e
+ Text.RE.Options: Options :: !(Macros r) -> !c -> !e -> Options_ r c e
- Text.RE.Replace: class (Extract a, Monoid a) => Replace a where textify = pack . unpack_ detextify = pack_ . unpack appendNewline = (<> pack_ "\n") subst f m@(Capture {..}) = capturePrefix m <> f capturedText <> captureSuffix m
+ Text.RE.Replace: class (Extract a, Monoid a) => Replace a where textifyE = pack . unpackE detextifyE = packE . unpack appendNewlineE = (<> packE "\n") substE f m@(Capture {..}) = capturePrefix m <> f capturedText <> captureSuffix m
- Text.RE.Replace: expandMacros :: (r -> String) -> Mode -> Macros r -> String -> String
+ Text.RE.Replace: expandMacros :: (r -> String) -> Macros r -> String -> String
- Text.RE.Replace: replaceAllCaptures :: Replace a => Phi a -> Matches a -> a
+ Text.RE.Replace: replaceAllCaptures :: Replace a => Context -> (Match a -> Location -> Capture a -> Maybe a) -> Matches a -> a
- Text.RE.Replace: replaceAllCapturesM :: (Extract a, Monad m) => Replace_ a -> Context -> (Match a -> Location -> Capture a -> m (Maybe a)) -> Matches a -> m a
+ Text.RE.Replace: replaceAllCapturesM :: (Extract a, Monad m) => ReplaceMethods a -> Context -> (Match a -> Location -> Capture a -> m (Maybe a)) -> Matches a -> m a
- Text.RE.Replace: replaceAllCaptures_ :: Extract a => Replace_ a -> Context -> (Match a -> Location -> Capture a -> Maybe a) -> Matches a -> a
+ Text.RE.Replace: replaceAllCaptures_ :: Extract a => ReplaceMethods a -> Context -> (Match a -> Location -> Capture a -> Maybe a) -> Matches a -> a
- Text.RE.Replace: replaceCaptures :: Replace a => Phi a -> Match a -> a
+ Text.RE.Replace: replaceCaptures :: Replace a => Context -> (Match a -> Location -> Capture a -> Maybe a) -> Match a -> a
- Text.RE.Replace: replaceCapturesM :: (Monad m, Extract a) => Replace_ a -> Context -> (Match a -> Location -> Capture a -> m (Maybe a)) -> Match a -> m a
+ Text.RE.Replace: replaceCapturesM :: (Monad m, Extract a) => ReplaceMethods a -> Context -> (Match a -> Location -> Capture a -> m (Maybe a)) -> Match a -> m a
- Text.RE.Replace: replaceCaptures_ :: Extract a => Replace_ a -> Context -> (Match a -> Location -> Capture a -> Maybe a) -> Match a -> a
+ Text.RE.Replace: replaceCaptures_ :: Extract a => ReplaceMethods a -> Context -> (Match a -> Location -> Capture a -> Maybe a) -> Match a -> a

Files

README.markdown view
@@ -21,9 +21,12 @@  ## regex and regex-examples -  * the `regex` package contains the regex library+The library and tutorial, tests and examples have been split across+two packages:++  * the `regex` package contains the regex library and   * the `regex-examples` package contains the tutorial, tests-    and example programs+    and example programs.   ## Road Map@@ -44,8 +47,10 @@  &nbsp;&nbsp;&nbsp;&nbsp;&#x2612;&nbsp;&nbsp;2017-02-22  v0.2.0.4  [Repair re-gen-modules-test for Windows](https://github.com/iconnect/regex/issues/47) -&nbsp;&nbsp;&nbsp;&nbsp;&#x2610;&nbsp;&nbsp;2017-02-26  v0.3.0.0  [API adjustments, tutorials and examples finalized](https://github.com/iconnect/regex/milestone/2)+&nbsp;&nbsp;&nbsp;&nbsp;&#x2612;&nbsp;&nbsp;2017-02-26  v0.3.0.0  [API adjustments](https://github.com/iconnect/regex/milestone/2) +&nbsp;&nbsp;&nbsp;&nbsp;&#x2610;&nbsp;&nbsp;2017-03-05  v0.5.0.0  [Ready for review: tutorials and examples finalized](https://github.com/iconnect/regex/milestone/6)+ &nbsp;&nbsp;&nbsp;&nbsp;&#x2610;&nbsp;&nbsp;2017-03-20  v1.0.0.0  [First stable release](https://github.com/iconnect/regex/milestone/3)  &nbsp;&nbsp;&nbsp;&nbsp;&#x2610;&nbsp;&nbsp;2017-08-31  v2.0.0.0  [Fast text replacement with benchmarks](https://github.com/iconnect/regex/milestone/4)@@ -53,6 +58,12 @@   See the [Roadmap page](http://roadmap.regex.uk) for details.+++## The regex blog++Check out the [regex blog](http://blog.regex.uk) for news articles and+discussion concerning all things regex.   ## Build Status
Text/RE.hs view
@@ -18,7 +18,7 @@   -- ** The Match Operators   -- $operators -  -- * Matches, Match, Capture Types and Functions+  -- * Matches, Match & Capture     Matches(..)   , Match(..)   , Capture(..)@@ -50,7 +50,6 @@   -- * Options   , Options_(..)   , IsOption(..)-  , Mode(..)   , MacroID(..)   , Macros   , emptyMacros@@ -96,20 +95,17 @@   , severityKeywords   -- * Replace   , Replace(..)-  , Replace_(..)-  , replace_-  , Phi(..)+  , ReplaceMethods(..)+  , replaceMethods   , Context(..)   , Location(..)   , isTopLocation   , replace   , replaceAll   , replaceAllCaptures-  , replaceAllCaptures'   , replaceAllCaptures_   , replaceAllCapturesM   , replaceCaptures-  , replaceCaptures'   , replaceCaptures_   , replaceCapturesM   , expandMacros
Text/RE/Capture.lhs view
@@ -143,7 +143,7 @@ mainCaptures :: Matches a -> [Capture a] mainCaptures ac = [ capture c0 cs | cs<-allMatches ac ]   where-    c0 = CID_ordinal $ CaptureOrdinal 0+    c0 = IsCaptureOrdinal $ CaptureOrdinal 0 \end{code}  
Text/RE/CaptureID.hs view
@@ -9,28 +9,38 @@ import qualified Data.Text                      as T  +-- | CaptureID identifies captures, either by number+-- (e.g., [cp|1|]) or name (e.g., [cp|foo|]). data CaptureID-  = CID_ordinal CaptureOrdinal-  | CID_name    CaptureName+  = IsCaptureOrdinal CaptureOrdinal+  | IsCaptureName    CaptureName   deriving (Show,Ord,Eq) +-- | the dictionary for named captures stored in compiled regular+-- expressions associates type CaptureNames = HMS.HashMap CaptureName CaptureOrdinal +-- | an empty 'CaptureNames' dictionary noCaptureNames :: CaptureNames noCaptureNames = HMS.empty +-- | a 'CaptureName' is just the text of the name newtype CaptureName = CaptureName { getCaptureName :: T.Text }   deriving (Show,Ord,Eq)  instance Hashable CaptureName where   hashWithSalt i = hashWithSalt i . getCaptureName +-- | a 'CaptureOrdinal' is just the number of the capture, starting+-- with 0 for the whole of the text matched, then in leftmost,+-- outermost newtype CaptureOrdinal = CaptureOrdinal { getCaptureOrdinal :: Int }   deriving (Show,Ord,Eq,Enum,Ix,Num) +-- | look up a 'CaptureID' in the 'CaptureNames' dictionary findCaptureID :: CaptureID -> CaptureNames -> Int-findCaptureID (CID_ordinal o) _   = getCaptureOrdinal o-findCaptureID (CID_name    n) hms =+findCaptureID (IsCaptureOrdinal o) _   = getCaptureOrdinal o+findCaptureID (IsCaptureName    n) hms =     getCaptureOrdinal $ fromMaybe oops $ HMS.lookup n hms   where     oops = error $ unlines $
Text/RE/Edit.lhs view
@@ -29,10 +29,9 @@   | Pipe   [(re,Edit m s)]  data Edit m s-  = EDIT_tpl s-  | EDIT_phi (Phi s)-  | EDIT_fun Context (LineNo->Match s->Location->Capture s->m (Maybe s))-  | EDIT_gen         (LineNo->Matches s->m (LineEdit s))+  = Template s+  | Function Context (LineNo->Match s->Location->Capture s->m (Maybe s))+  | LineEdit         (LineNo->Matches s->m (LineEdit s))  data LineEdit s   = NoEdit@@ -60,10 +59,9 @@   case allMatches acs of     [] -> return Nothing     _  -> fmap Just $ case edit of-      EDIT_tpl tpl   -> return $ anl $ replaceAll         tpl acs-      EDIT_phi phi   -> return $ anl $ replaceAllCaptures phi acs-      EDIT_fun ctx f -> anl <$> replaceAllCapturesM replace_ ctx (f lno) acs-      EDIT_gen     g -> fromMaybe s' . applyLineEdit anl <$> g lno acs+      Template tpl   -> return $ anl $ replaceAll         tpl acs+      Function ctx f -> anl <$> replaceAllCapturesM replaceMethods ctx (f lno) acs+      LineEdit     g -> fromMaybe s' . applyLineEdit anl <$> g lno acs   where     s'  = anl s     acs = matchMany re s@@ -80,9 +78,9 @@                     -> m s select_edit_scripts lno ps0 s = select ps0   where-    select []           = return $ appendNewline s+    select []           = return $ appendNewlineE s     select ((re,es):ps) =-      applyEdit appendNewline lno re es s >>= maybe (select ps) return+      applyEdit appendNewlineE lno re es s >>= maybe (select ps) return  pipe_edit_scripts :: (IsRegex re s,Monad m,Functor m)                   => LineNo@@ -90,7 +88,7 @@                   -> s                   -> m s pipe_edit_scripts lno ez s0 =-    appendNewline <$> foldr f (return s0) ez+    appendNewlineE <$> foldr f (return s0) ez   where     f (re,es) act = do       s <- act
Text/RE/Internal/NamedCaptures.lhs view
@@ -110,7 +110,7 @@       , mk [here|(.)|]              $         Other . s2c . x_1       ] -    x_1     = captureText $ CID_ordinal $ CaptureOrdinal 1+    x_1     = captureText $ IsCaptureOrdinal $ CaptureOrdinal 1      s2c [c] = c     s2c _   = error "scan:s2c:internal error"@@ -127,8 +127,8 @@ \begin{code} parse_capture :: String -> TH.Q TH.Exp parse_capture s = case all isDigit s of-  True  -> [|CID_ordinal $ CaptureOrdinal $ read s|]-  False -> [|CID_name    $ CaptureName $ T.pack  s|]+  True  -> [|IsCaptureOrdinal $ CaptureOrdinal $ read s|]+  False -> [|IsCaptureName    $ CaptureName $ T.pack  s|] \end{code}  
Text/RE/Internal/PreludeMacros.hs view
@@ -192,8 +192,8 @@     samples =       [ (,) "0"         0x0       , (,) "12345678"  0x12345678-      , (,) "90abcdef"  0x90abcdef-      , (,) "90ABCDEF"  0x90abcdef+      , (,) "0abcdef"   0xabcdef+      , (,) "0ABCDEF"   0xabcdef       , (,) "00"        0x0       , (,) "010"       0x10       ]
Text/RE/Options.lhs view
@@ -17,10 +17,9 @@ \begin{code} data Options_ r c e =   Options-    { _options_mode :: !Mode-    , _options_macs :: !(Macros r)-    , _options_comp :: !c-    , _options_exec :: !e+    { optionsMacs :: !(Macros r)+    , optionsComp :: !c+    , optionsExec :: !e     }   deriving (Show) \end{code}@@ -32,21 +31,14 @@ \end{code}  \begin{code}-data Mode-  = Simple-  | Block-  deriving (Bounded,Enum,Ord,Eq,Show)-\end{code}--\begin{code} newtype MacroID =-    MacroID { _MacroID :: String }+    MacroID { getMacroID :: String }   deriving (IsString,Ord,Eq,Show) \end{code}  \begin{code} instance Hashable MacroID where-  hashWithSalt i = hashWithSalt i . _MacroID+  hashWithSalt i = hashWithSalt i . getMacroID \end{code}  \begin{code}
Text/RE/PCRE.hs view
@@ -6,12 +6,23 @@ {-# OPTIONS_GHC -fno-warn-dodgy-exports #-}  module Text.RE.PCRE-  ( (*=~)+  (+  -- * Tutorial+  -- $tutorial++  -- * The Overloaded Match Operators+    (*=~)   , (?=~)   , (=~)   , (=~~)+  -- * The Toolkit+  -- $toolkit   , module Text.RE+  -- * The 'RE' Type+  -- $re   , module Text.RE.PCRE.RE+  -- * The Operator Instances+  -- $instances   , module Text.RE.PCRE.ByteString   , module Text.RE.PCRE.ByteString.Lazy   , module Text.RE.PCRE.Sequence@@ -31,18 +42,21 @@ import           Text.RE.PCRE.String()  +-- | find all matches in text (*=~) :: IsRegex RE s       => s       -> RE       -> Matches s (*=~) bs rex = addCaptureNamesToMatches (reCaptureNames rex) $ matchMany rex bs +-- | find first match in text (?=~) :: IsRegex RE s       => s       -> RE       -> Match s (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ matchOnce rex bs +-- | the regex-base polymorphic match operator (=~) :: ( B.RegexContext PCRE.Regex s a         , B.RegexMaker   PCRE.Regex PCRE.CompOption PCRE.ExecOption s         )@@ -51,6 +65,7 @@      -> a (=~) bs rex = B.match (reRegex rex) bs +-- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m          , B.RegexContext PCRE.Regex s a          , B.RegexMaker   PCRE.Regex PCRE.CompOption PCRE.ExecOption s@@ -59,3 +74,23 @@       -> RE       -> m a (=~~) bs rex = B.matchM (reRegex rex) bs++-- $tutorial+-- We have a regex tutorial at <http://tutorial.regex.uk>. These API+-- docs are mainly for reference.++-- $toolkit+--+-- Beyond the above match operators and the regular expression type+-- below, "Text.RE" contains the toolkit for replacing captures,+-- specifying options, etc.++-- $re+--+-- "Text.RE.TDFA.RE" contains the toolkit specific to the 'RE' type,+-- the type generated by the gegex compiler.++-- $instances+--+-- These modules merely provide the instances for the above regex+-- match operators at the various text types.
Text/RE/PCRE/ByteString.hs view
@@ -8,11 +8,20 @@ #endif  module Text.RE.PCRE.ByteString-  ( (*=~)+  (+  -- * Tutorial+  -- $tutorial++  -- * The Match Operators+    (*=~)   , (?=~)   , (=~)   , (=~~)+  -- * The Toolkit+  -- $toolkit   , module Text.RE+  -- * The 'RE' Type+  -- $re   , module Text.RE.PCRE.RE   ) where @@ -30,13 +39,13 @@       -> Matches B.ByteString (*=~) bs rex = addCaptureNamesToMatches (reCaptureNames rex) $ match (reRegex rex) bs --- | find first matches in text+-- | find first match in text (?=~) :: B.ByteString       -> RE       -> Match B.ByteString (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs --- | regex-base polymorphic match operator+-- | the regex-base polymorphic match operator (=~) :: ( RegexContext PCRE.Regex B.ByteString a         , RegexMaker   PCRE.Regex PCRE.CompOption PCRE.ExecOption String         )@@ -45,7 +54,7 @@      -> a (=~) bs rex = match (reRegex rex) bs --- | regex-base monadic, polymorphic match operator+-- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m          , RegexContext PCRE.Regex B.ByteString a          , RegexMaker   PCRE.Regex PCRE.CompOption PCRE.ExecOption String@@ -59,3 +68,18 @@   matchOnce   = flip (?=~)   matchMany   = flip (*=~)   regexSource = reSource++-- $tutorial+-- We have a regex tutorial at <http://tutorial.regex.uk>. These API+-- docs are mainly for reference.++-- $toolkit+--+-- Beyond the above match operators and the regular expression type+-- below, "Text.RE" contains the toolkit for replacing captures,+-- specifying options, etc.++-- $re+--+-- "Text.RE.PCRE.RE" contains the toolkit specific to the 'RE' type,+-- the type generated by the gegex compiler.
Text/RE/PCRE/ByteString/Lazy.hs view
@@ -8,11 +8,20 @@ #endif  module Text.RE.PCRE.ByteString.Lazy-  ( (*=~)+  (+  -- * Tutorial+  -- $tutorial++  -- * The Match Operators+    (*=~)   , (?=~)   , (=~)   , (=~~)+  -- * The Toolkit+  -- $toolkit   , module Text.RE+  -- * The 'RE' Type+  -- $re   , module Text.RE.PCRE.RE   ) where @@ -30,13 +39,13 @@       -> Matches LBS.ByteString (*=~) bs rex = addCaptureNamesToMatches (reCaptureNames rex) $ match (reRegex rex) bs --- | find first matches in text+-- | find first match in text (?=~) :: LBS.ByteString       -> RE       -> Match LBS.ByteString (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs --- | regex-base polymorphic match operator+-- | the regex-base polymorphic match operator (=~) :: ( RegexContext PCRE.Regex LBS.ByteString a         , RegexMaker   PCRE.Regex PCRE.CompOption PCRE.ExecOption String         )@@ -45,7 +54,7 @@      -> a (=~) bs rex = match (reRegex rex) bs --- | regex-base monadic, polymorphic match operator+-- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m          , RegexContext PCRE.Regex LBS.ByteString a          , RegexMaker   PCRE.Regex PCRE.CompOption PCRE.ExecOption String@@ -59,3 +68,18 @@   matchOnce   = flip (?=~)   matchMany   = flip (*=~)   regexSource = reSource++-- $tutorial+-- We have a regex tutorial at <http://tutorial.regex.uk>. These API+-- docs are mainly for reference.++-- $toolkit+--+-- Beyond the above match operators and the regular expression type+-- below, "Text.RE" contains the toolkit for replacing captures,+-- specifying options, etc.++-- $re+--+-- "Text.RE.PCRE.RE" contains the toolkit specific to the 'RE' type,+-- the type generated by the gegex compiler.
Text/RE/PCRE/RE.hs view
@@ -107,17 +107,14 @@ instance IsOption SimpleRegexOptions RE CompOption ExecOption where   makeOptions    = unpackSimpleRegexOptions -instance IsOption Mode        RE CompOption ExecOption where-  makeOptions md = Options md prelude def_comp_option def_exec_option- instance IsOption (Macros RE) RE CompOption ExecOption where-  makeOptions ms = Options minBound ms def_comp_option def_exec_option+  makeOptions ms = Options ms def_comp_option def_exec_option  instance IsOption CompOption  RE CompOption ExecOption where-  makeOptions co = Options minBound prelude co def_exec_option+  makeOptions co = Options prelude co def_exec_option  instance IsOption ExecOption  RE CompOption ExecOption where-  makeOptions eo = Options minBound prelude def_comp_option eo+  makeOptions eo = Options prelude def_comp_option eo  instance IsOption Options     RE CompOption ExecOption where   makeOptions    = id@@ -126,13 +123,13 @@   makeOptions _  = unpackSimpleRegexOptions minBound  def_comp_option :: CompOption-def_comp_option = _options_comp defaultOptions+def_comp_option = optionsComp defaultOptions  def_exec_option :: ExecOption-def_exec_option = _options_exec defaultOptions+def_exec_option = optionsExec defaultOptions  noPreludeOptions :: Options-noPreludeOptions = defaultOptions { _options_macs = emptyMacros }+noPreludeOptions = defaultOptions { optionsMacs = emptyMacros }  defaultOptions :: Options defaultOptions = makeOptions (minBound::SimpleRegexOptions)@@ -140,10 +137,9 @@ unpackSimpleRegexOptions :: SimpleRegexOptions -> Options unpackSimpleRegexOptions sro =   Options-    { _options_mode = minBound-    , _options_macs = prelude-    , _options_comp = comp-    , _options_exec = defaultExecOpt+    { optionsMacs = prelude+    , optionsComp = comp+    , optionsExec = defaultExecOpt     }   where     comp =@@ -221,9 +217,9 @@               -> m (CaptureNames,Regex) compileRegex' Options{..} s0 = do     (cnms,s2) <- either fail return $ extractNamedCaptures s1-    (,) cnms <$> makeRegexOptsM _options_comp _options_exec s2+    (,) cnms <$> makeRegexOptsM optionsComp optionsExec s2   where-    s1 = expandMacros reSource _options_mode _options_macs s0+    s1 = expandMacros reSource optionsMacs s0  prelude :: Macros RE prelude = runIdentity $ preludeMacros mk PCRE ExclCaptures
Text/RE/PCRE/Sequence.hs view
@@ -8,11 +8,20 @@ #endif  module Text.RE.PCRE.Sequence-  ( (*=~)+  (+  -- * Tutorial+  -- $tutorial++  -- * The Match Operators+    (*=~)   , (?=~)   , (=~)   , (=~~)+  -- * The Toolkit+  -- $toolkit   , module Text.RE+  -- * The 'RE' Type+  -- $re   , module Text.RE.PCRE.RE   ) where @@ -30,13 +39,13 @@       -> Matches (S.Seq Char) (*=~) bs rex = addCaptureNamesToMatches (reCaptureNames rex) $ match (reRegex rex) bs --- | find first matches in text+-- | find first match in text (?=~) :: (S.Seq Char)       -> RE       -> Match (S.Seq Char) (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs --- | regex-base polymorphic match operator+-- | the regex-base polymorphic match operator (=~) :: ( RegexContext PCRE.Regex (S.Seq Char) a         , RegexMaker   PCRE.Regex PCRE.CompOption PCRE.ExecOption String         )@@ -45,7 +54,7 @@      -> a (=~) bs rex = match (reRegex rex) bs --- | regex-base monadic, polymorphic match operator+-- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m          , RegexContext PCRE.Regex (S.Seq Char) a          , RegexMaker   PCRE.Regex PCRE.CompOption PCRE.ExecOption String@@ -59,3 +68,18 @@   matchOnce   = flip (?=~)   matchMany   = flip (*=~)   regexSource = reSource++-- $tutorial+-- We have a regex tutorial at <http://tutorial.regex.uk>. These API+-- docs are mainly for reference.++-- $toolkit+--+-- Beyond the above match operators and the regular expression type+-- below, "Text.RE" contains the toolkit for replacing captures,+-- specifying options, etc.++-- $re+--+-- "Text.RE.PCRE.RE" contains the toolkit specific to the 'RE' type,+-- the type generated by the gegex compiler.
Text/RE/PCRE/String.hs view
@@ -8,11 +8,20 @@ #endif  module Text.RE.PCRE.String-  ( (*=~)+  (+  -- * Tutorial+  -- $tutorial++  -- * The Match Operators+    (*=~)   , (?=~)   , (=~)   , (=~~)+  -- * The Toolkit+  -- $toolkit   , module Text.RE+  -- * The 'RE' Type+  -- $re   , module Text.RE.PCRE.RE   ) where @@ -30,13 +39,13 @@       -> Matches String (*=~) bs rex = addCaptureNamesToMatches (reCaptureNames rex) $ match (reRegex rex) bs --- | find first matches in text+-- | find first match in text (?=~) :: String       -> RE       -> Match String (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs --- | regex-base polymorphic match operator+-- | the regex-base polymorphic match operator (=~) :: ( RegexContext PCRE.Regex String a         , RegexMaker   PCRE.Regex PCRE.CompOption PCRE.ExecOption String         )@@ -45,7 +54,7 @@      -> a (=~) bs rex = match (reRegex rex) bs --- | regex-base monadic, polymorphic match operator+-- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m          , RegexContext PCRE.Regex String a          , RegexMaker   PCRE.Regex PCRE.CompOption PCRE.ExecOption String@@ -59,3 +68,18 @@   matchOnce   = flip (?=~)   matchMany   = flip (*=~)   regexSource = reSource++-- $tutorial+-- We have a regex tutorial at <http://tutorial.regex.uk>. These API+-- docs are mainly for reference.++-- $toolkit+--+-- Beyond the above match operators and the regular expression type+-- below, "Text.RE" contains the toolkit for replacing captures,+-- specifying options, etc.++-- $re+--+-- "Text.RE.PCRE.RE" contains the toolkit specific to the 'RE' type,+-- the type generated by the gegex compiler.
Text/RE/Parsers.hs view
@@ -36,19 +36,19 @@   parseInteger :: Replace a => a -> Maybe Int-parseInteger = readMaybe . unpack_+parseInteger = readMaybe . unpackE  parseHex :: Replace a => a -> Maybe Int-parseHex = readMaybe . ("0x"++) . unpack_+parseHex = readMaybe . ("0x"++) . unpackE  parseDouble :: Replace a => a -> Maybe Double-parseDouble = readMaybe . unpack_+parseDouble = readMaybe . unpackE  parseString :: Replace a => a -> Maybe T.Text-parseString = readMaybe . unpack_+parseString = readMaybe . unpackE  parseSimpleString :: Replace a => a -> Maybe T.Text-parseSimpleString = Just . T.dropEnd 1 . T.drop 1 . textify+parseSimpleString = Just . T.dropEnd 1 . T.drop 1 . textifyE  date_templates, time_templates, timezone_templates,   date_time_8601_templates, date_time_templates :: [String]@@ -91,10 +91,10 @@ parseDateTimeCLF = parse_time ["%d/%b/%Y:%H:%M:%S %z"]  parseShortMonth :: Replace a => a -> Maybe Int-parseShortMonth = flip HM.lookup short_month_hm . unpack_+parseShortMonth = flip HM.lookup short_month_hm . unpackE  parse_time :: (ParseTime t,Replace s) => [String] -> s -> Maybe t-parse_time tpls = prs . unpack_+parse_time tpls = prs . unpackE   where     prs s = listToMaybe $ catMaybes       [ parseTime LC.defaultTimeLocale fmt s@@ -111,7 +111,7 @@ type IPV4Address = (Word8,Word8,Word8,Word8)  parseIPv4Address :: Replace a => a -> Maybe IPV4Address-parseIPv4Address = prs . words_by (=='.') . unpack_+parseIPv4Address = prs . words_by (=='.') . unpackE   where     prs [a_s,b_s,c_s,d_s] = do       a <- readMaybe a_s@@ -137,7 +137,7 @@   deriving (Bounded,Enum,Ord,Eq,Show)  parseSeverity :: Replace a => a -> Maybe Severity-parseSeverity = flip HM.lookup severity_hm . textify+parseSeverity = flip HM.lookup severity_hm . textifyE  severity_hm :: HM.HashMap T.Text Severity severity_hm = HM.fromList
Text/RE/Replace.lhs view
@@ -8,20 +8,17 @@  module Text.RE.Replace   ( Replace(..)-  , Replace_(..)-  , replace_-  , Phi(..)+  , ReplaceMethods(..)+  , replaceMethods   , Context(..)   , Location(..)   , isTopLocation   , replace   , replaceAll   , replaceAllCaptures-  , replaceAllCaptures'   , replaceAllCaptures_   , replaceAllCapturesM   , replaceCaptures-  , replaceCaptures'   , replaceCaptures_   , replaceCapturesM   , expandMacros@@ -54,67 +51,54 @@  \begin{code} -- | Replace provides the missing methods needed to replace the matched--- text; length_ is the minimum implementation+-- text; lengthE is the minimum implementation class (Extract a,Monoid a) => Replace a where   -- | length function for a-  length_       :: a -> Int+  lengthE        :: a -> Int   -- | inject String into a-  pack_         :: String -> a+  packE          :: String -> a   -- | project a onto a String-  unpack_       :: a -> String+  unpackE        :: a -> String   -- | inject into Text-  textify       :: a -> T.Text+  textifyE       :: a -> T.Text   -- | project Text onto a-  detextify     :: T.Text -> a+  detextifyE     :: T.Text -> a   -- | append a newline-  appendNewline :: a -> a+  appendNewlineE :: a -> a   -- | apply a substitution function to a Capture-  subst         :: (a->a) -> Capture a -> a+  substE         :: (a->a) -> Capture a -> a   -- | convert a template containing $0, $1, etc., in the first   -- argument, into a 'phi' replacement function for use with-  -- replaceAllCaptures' and replaceCaptures'-  parse_tpl     :: a -> Match a -> Location -> Capture a -> Maybe a+  -- replaceAllCaptures and replaceCaptures+  parseTemplateE :: a -> Match a -> Location -> Capture a -> Maybe a -  textify       = T.pack . unpack_-  detextify     = pack_  . T.unpack-  appendNewline = (<> pack_ "\n")+  textifyE       = T.pack . unpackE+  detextifyE     = packE  . T.unpack+  appendNewlineE = (<> packE "\n") -  subst f m@Capture{..} =+  substE f m@Capture{..} =     capturePrefix m <> f capturedText <> captureSuffix m \end{code}  \begin{code}--- | a selction of the Replace methods can be encapsulated with Replace_+-- | a selction of the Replace methods can be encapsulated with ReplaceMethods -- for the higher-order replacement functions-data Replace_ a =-  Replace_-    { _r_length :: a -> Int-    , _r_subst  :: (a->a) -> Capture a -> a+data ReplaceMethods a =+  ReplaceMethods+    { methodLength :: a -> Int+    , methodSubst  :: (a->a) -> Capture a -> a     } --- | replace_ encapsulates Replace_ a from a Replace a context-replace_ :: Replace a => Replace_ a-replace_ =-  Replace_-    { _r_length = length_-    , _r_subst  = subst+-- | replaceMethods encapsulates ReplaceMethods a from a Replace a context+replaceMethods :: Replace a => ReplaceMethods a+replaceMethods =+  ReplaceMethods+    { methodLength = lengthE+    , methodSubst  = substE     } \end{code}  \begin{code}--- | @Phi@ specifies the substitution function for procesing the substrings--- captured by the regular expression.-data Phi a =-  Phi-    { _phi_context :: Context             -- ^ the context for applying-                                          -- the substitution-    , _phi_phi     :: Location -> a -> a  -- ^ the substitution function-                                          -- takes the location and-                                          -- the text to be replaced and-                                          -- returns the replacement-                                          -- text to be substituted-    }- -- | @Context@ specifies which contexts the substitutions should be applied data Context   = TOP   -- ^ substitutions should be applied to the top-level only,@@ -129,15 +113,15 @@ -- specifies which sub-expression is being substituted data Location =   Location-    { _loc_match   :: Int   -- ^ the zero-based, i-th string to be-                            -- matched, when matching all strings,-                            -- zero when only the first string is-                            -- being matched-    , _loc_capture :: CaptureOrdinal-                            -- ^ 0, when matching the top-level-                            -- string matched by the whole RE, 1-                            -- for the top-most, left-most redex-                            -- captured by bracketed sub-REs, etc.+    { locationMatch   :: Int+                        -- ^ the zero-based, i-th string to be matched,+                        -- when matching all strings, zero when only the+                        -- first string is being matched+    , locationCapture :: CaptureOrdinal+                        -- ^ 0, when matching the top-level string+                        -- matched by the whole RE, 1 for the top-most,+                        -- left-most redex captured by bracketed+                        -- sub-REs, etc.     }   deriving (Show) \end{code}@@ -146,7 +130,7 @@ -- | True iff the location references a complete match -- (i.e., not a bracketed capture) isTopLocation :: Location -> Bool-isTopLocation = (==0) . _loc_capture+isTopLocation = (==0) . locationCapture \end{code}  \begin{code}@@ -156,38 +140,29 @@            => a            -> Matches a            -> a-replaceAll tpl ac = replaceAllCaptures' TOP (parse_tpl tpl) ac-\end{code}--\begin{code}--- | substitutes the PHI substitutions through the Matches-replaceAllCaptures :: Replace a-                   => Phi a-                   -> Matches a-                   -> a-replaceAllCaptures = mk_phi replaceAllCaptures'+replaceAll tpl ac = replaceAllCaptures TOP (parseTemplateE tpl) ac \end{code}  \begin{code} -- | substitutes using a function that takes the full Match -- context and returns the same replacement text as the _phi_phi -- context.-replaceAllCaptures' :: Replace a-                    => Context-                    -> (Match a->Location->Capture a->Maybe a)-                    -> Matches a-                    -> a+replaceAllCaptures :: Replace a+                   => Context+                   -> (Match a->Location->Capture a->Maybe a)+                   -> Matches a+                   -> a \end{code}  \begin{code}-replaceAllCaptures' = replaceAllCaptures_ replace_+replaceAllCaptures = replaceAllCaptures_ replaceMethods \end{code}  \begin{code}--- | replaceAllCaptures_ is like like replaceAllCaptures' but takes the--- Replace methods through the Replace_ argument+-- | replaceAllCaptures_ is like like replaceAllCaptures but takes the+-- Replace methods through the ReplaceMethods argument replaceAllCaptures_ :: Extract a-                    => Replace_ a+                    => ReplaceMethods a                     -> Context                     -> (Match a->Location->Capture a->Maybe a)                     -> Matches a@@ -200,7 +175,7 @@ -- | replaceAllCapturesM is just a monadically generalised version of -- replaceAllCaptures_ replaceAllCapturesM :: (Extract a,Monad m)-                    => Replace_ a+                    => ReplaceMethods a                     -> Context                     -> (Match a->Location->Capture a->m (Maybe a))                     -> Matches a@@ -250,35 +225,26 @@         => Match a         -> a         -> a-replace c tpl = replaceCaptures' TOP (parse_tpl tpl) c-\end{code}--\begin{code}--- | substitutes the PHI substitutions through the Match-replaceCaptures :: Replace a-                => Phi a-                -> Match a-                -> a-replaceCaptures = mk_phi replaceCaptures'+replace c tpl = replaceCaptures TOP (parseTemplateE tpl) c \end{code}  \begin{code} -- | substitutes using a function that takes the full Match -- context and returns the same replacement text as the _phi_phi -- context.-replaceCaptures' :: Replace a+replaceCaptures :: Replace a                  => Context                  -> (Match a->Location->Capture a->Maybe a)                  -> Match a                  -> a-replaceCaptures' = replaceCaptures_ replace_+replaceCaptures = replaceCaptures_ replaceMethods \end{code}  \begin{code}--- | replaceCaptures_ is like replaceCaptures' but takes the Replace methods--- through the Replace_ argument+-- | replaceCaptures_ is like replaceCaptures but takes the Replace methods+-- through the ReplaceMethods argument replaceCaptures_ :: Extract a-                 => Replace_ a+                 => ReplaceMethods a                  -> Context                  -> (Match a->Location->Capture a->Maybe a)                  -> Match a@@ -291,12 +257,12 @@ -- | replaceCapturesM is just a monadically generalised version of -- replaceCaptures_ replaceCapturesM :: (Monad m,Extract a)-                 => Replace_ a+                 => ReplaceMethods a                  -> Context                  -> (Match a->Location->Capture a->m (Maybe a))                  -> Match a                  -> m a-replaceCapturesM Replace_{..} ctx phi_ caps@Match{..} = do+replaceCapturesM ReplaceMethods{..} ctx phi_ caps@Match{..} = do     (hay',_) <- foldr sc (return (matchSource,[])) $                     zip [0..] $ elems matchArray     return hay'@@ -310,12 +276,12 @@         Nothing   -> return (hay,ds)         Just ndl' ->             return-              ( _r_subst (const ndl') cap+              ( methodSubst (const ndl') cap               , (captureOffset cap,len'-len) : ds               )           where-            len' = _r_length ndl'-            len  = _r_length ndl+            len' = methodLength ndl'+            len  = methodLength ndl      adj hay ds cap =       Capture@@ -346,72 +312,66 @@ -- the Replace instances  instance Replace [Char] where-  length_       = length-  pack_         = id-  unpack_       = id-  textify       = T.pack-  detextify     = T.unpack-  appendNewline = (<>"\n")-  parse_tpl     = parse_tpl_ id+  lengthE         = length+  packE           = id+  unpackE         = id+  textifyE        = T.pack+  detextifyE      = T.unpack+  appendNewlineE  = (<>"\n")+  parseTemplateE  = parseTemplateE' id  instance Replace B.ByteString where-  length_   = B.length-  pack_     = B.pack-  unpack_   = B.unpack-  textify   = TE.decodeUtf8-  detextify = TE.encodeUtf8-  appendNewline = (<>"\n")-  parse_tpl = parse_tpl_ B.unpack+  lengthE         = B.length+  packE           = B.pack+  unpackE         = B.unpack+  textifyE        = TE.decodeUtf8+  detextifyE      = TE.encodeUtf8+  appendNewlineE  = (<>"\n")+  parseTemplateE  = parseTemplateE' B.unpack  instance Replace LBS.ByteString where-  length_   = fromEnum . LBS.length-  pack_     = LBS.pack-  unpack_   = LBS.unpack-  textify   = TE.decodeUtf8  . LBS.toStrict-  detextify = LBS.fromStrict . TE.encodeUtf8-  appendNewline = (<>"\n")-  parse_tpl = parse_tpl_ LBS.unpack+  lengthE         = fromEnum . LBS.length+  packE           = LBS.pack+  unpackE         = LBS.unpack+  textifyE        = TE.decodeUtf8  . LBS.toStrict+  detextifyE      = LBS.fromStrict . TE.encodeUtf8+  appendNewlineE  = (<>"\n")+  parseTemplateE  = parseTemplateE' LBS.unpack  instance Replace (S.Seq Char) where-  length_   = S.length-  pack_     = S.fromList-  unpack_   = F.toList-  parse_tpl = parse_tpl_ F.toList+  lengthE         = S.length+  packE           = S.fromList+  unpackE         = F.toList+  parseTemplateE  = parseTemplateE' F.toList  instance Replace T.Text where-  length_   = T.length-  pack_     = T.pack-  unpack_   = T.unpack-  textify   = id-  detextify = id-  appendNewline = (<>"\n")-  parse_tpl = parse_tpl_ T.unpack+  lengthE         = T.length+  packE           = T.pack+  unpackE         = T.unpack+  textifyE        = id+  detextifyE      = id+  appendNewlineE  = (<>"\n")+  parseTemplateE  = parseTemplateE' T.unpack  instance Replace LT.Text where-  length_   = fromEnum . LT.length-  pack_     = LT.pack-  unpack_   = LT.unpack-  textify   = LT.toStrict-  detextify = LT.fromStrict-  appendNewline = (<>"\n")-  parse_tpl = parse_tpl_ LT.unpack+  lengthE         = fromEnum . LT.length+  packE           = LT.pack+  unpackE         = LT.unpack+  textifyE        = LT.toStrict+  detextifyE      = LT.fromStrict+  appendNewlineE  = (<>"\n")+  parseTemplateE  = parseTemplateE' LT.unpack \end{code}  \begin{code} -- | expand all of the @{..} macros in the RE in the argument String -- according to the Macros argument, preprocessing the RE String -- according to the Mode argument (used internally)-expandMacros :: (r->String) -> Mode -> Macros r -> String -> String-expandMacros x_src md hm s0 =+expandMacros :: (r->String) -> Macros r -> String -> String+expandMacros x_src hm s =   case HM.null hm of     True  -> s     False -> expandMacros' (fmap x_src . flip HM.lookup hm) s-  where-    s = case md of-      Simple -> s0-      Block  -> concat $ map clean $ lines s0--    clean = reverse . dropWhile isSpace . reverse . dropWhile isSpace \end{code}  \begin{code}@@ -420,7 +380,7 @@ expandMacros' :: (MacroID->Maybe String) -> String -> String expandMacros' lu = fixpoint e_m   where-    e_m re_s = replaceAllCaptures' TOP phi $ re_s $=~ [here|@(@|\{([^{}]+)\})|]+    e_m re_s = replaceAllCaptures TOP phi $ re_s $=~ [here|@(@|\{([^{}]+)\})|]       where         phi mtch _ cap = case txt == "@@" of             True  -> Just   "@"@@ -428,7 +388,7 @@           where             txt = capturedText cap             ide = MacroID $ capturedText $ capture c2 mtch-            c2  = CID_ordinal $ CaptureOrdinal 2+            c2  = IsCaptureOrdinal $ CaptureOrdinal 2 \end{code}  \begin{code}@@ -438,18 +398,10 @@ lift_phi phi_ = phi   where     phi caps' loc' cap' = return $ phi_ caps' loc' cap'--mk_phi :: (Context->(Match a->Location->Capture a->Maybe a)->b)-       -> Phi a-       -> b-mk_phi f phi@Phi{..} = f _phi_context $ mk_phi' phi--mk_phi' :: Phi a -> Match a -> Location -> Capture a -> Maybe a-mk_phi' Phi{..} _ loc = Just . _phi_phi loc . capturedText \end{code}  \begin{code}-parse_tpl_ :: ( Replace a+parseTemplateE' :: ( Replace a               , RegexContext Regex a (Matches a)               , RegexMaker   Regex CompOption ExecOption String               )@@ -459,25 +411,25 @@            -> Location            -> Capture a            -> Maybe a-parse_tpl_ unpack tpl mtch _ _ =-    Just $ replaceAllCaptures' TOP phi $+parseTemplateE' unpack tpl mtch _ _ =+    Just $ replaceAllCaptures TOP phi $       tpl $=~ [here|\$(\$|[0-9]+|\{([^{}]+)\})|]   where     phi t_mtch _ _ = case t_mtch !$? c2  of-      Just cap -> this $ CID_name $ CaptureName txt+      Just cap -> this $ IsCaptureName $ CaptureName txt         where           txt = T.pack $ unpack $ capturedText cap       Nothing -> case s == "$" of         True  -> Just t-        False -> this $ CID_ordinal $ CaptureOrdinal $ read s+        False -> this $ IsCaptureOrdinal $ CaptureOrdinal $ read s       where         s  = unpack t         t  = capturedText $ capture c1 t_mtch          this cid = capturedText <$> mtch !$? cid -    c1 = CID_ordinal $ CaptureOrdinal 1-    c2 = CID_ordinal $ CaptureOrdinal 2+    c1 = IsCaptureOrdinal $ CaptureOrdinal 1+    c2 = IsCaptureOrdinal $ CaptureOrdinal 2 \end{code}  \begin{code}
Text/RE/TDFA.hs view
@@ -6,12 +6,23 @@ {-# OPTIONS_GHC -fno-warn-dodgy-exports #-}  module Text.RE.TDFA-  ( (*=~)+  (+  -- * Tutorial+  -- $tutorial++  -- * The Overloaded Match Operators+    (*=~)   , (?=~)   , (=~)   , (=~~)+  -- * The Toolkit+  -- $toolkit   , module Text.RE+  -- * The 'RE' Type+  -- $re   , module Text.RE.TDFA.RE+  -- * The Operator Instances+  -- $instances   , module Text.RE.TDFA.ByteString   , module Text.RE.TDFA.ByteString.Lazy   , module Text.RE.TDFA.Sequence@@ -34,18 +45,21 @@ import           Text.RE.TDFA.Text.Lazy()  +-- | find all matches in text (*=~) :: IsRegex RE s       => s       -> RE       -> Matches s (*=~) bs rex = addCaptureNamesToMatches (reCaptureNames rex) $ matchMany rex bs +-- | find first match in text (?=~) :: IsRegex RE s       => s       -> RE       -> Match s (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ matchOnce rex bs +-- | the regex-base polymorphic match operator (=~) :: ( B.RegexContext TDFA.Regex s a         , B.RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption s         )@@ -54,6 +68,7 @@      -> a (=~) bs rex = B.match (reRegex rex) bs +-- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m          , B.RegexContext TDFA.Regex s a          , B.RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption s@@ -62,3 +77,23 @@       -> RE       -> m a (=~~) bs rex = B.matchM (reRegex rex) bs++-- $tutorial+-- We have a regex tutorial at <http://tutorial.regex.uk>. These API+-- docs are mainly for reference.++-- $toolkit+--+-- Beyond the above match operators and the regular expression type+-- below, "Text.RE" contains the toolkit for replacing captures,+-- specifying options, etc.++-- $re+--+-- "Text.RE.TDFA.RE" contains the toolkit specific to the 'RE' type,+-- the type generated by the gegex compiler.++-- $instances+--+-- These modules merely provide the instances for the above regex+-- match operators at the various text types.
Text/RE/TDFA/ByteString.hs view
@@ -8,11 +8,20 @@ #endif  module Text.RE.TDFA.ByteString-  ( (*=~)+  (+  -- * Tutorial+  -- $tutorial++  -- * The Match Operators+    (*=~)   , (?=~)   , (=~)   , (=~~)+  -- * The Toolkit+  -- $toolkit   , module Text.RE+  -- * The 'RE' Type+  -- $re   , module Text.RE.TDFA.RE   ) where @@ -30,13 +39,13 @@       -> Matches B.ByteString (*=~) bs rex = addCaptureNamesToMatches (reCaptureNames rex) $ match (reRegex rex) bs --- | find first matches in text+-- | find first match in text (?=~) :: B.ByteString       -> RE       -> Match B.ByteString (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs --- | regex-base polymorphic match operator+-- | the regex-base polymorphic match operator (=~) :: ( RegexContext TDFA.Regex B.ByteString a         , RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption String         )@@ -45,7 +54,7 @@      -> a (=~) bs rex = match (reRegex rex) bs --- | regex-base monadic, polymorphic match operator+-- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m          , RegexContext TDFA.Regex B.ByteString a          , RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption String@@ -59,3 +68,18 @@   matchOnce   = flip (?=~)   matchMany   = flip (*=~)   regexSource = reSource++-- $tutorial+-- We have a regex tutorial at <http://tutorial.regex.uk>. These API+-- docs are mainly for reference.++-- $toolkit+--+-- Beyond the above match operators and the regular expression type+-- below, "Text.RE" contains the toolkit for replacing captures,+-- specifying options, etc.++-- $re+--+-- "Text.RE.TDFA.RE" contains the toolkit specific to the 'RE' type,+-- the type generated by the gegex compiler.
Text/RE/TDFA/ByteString/Lazy.hs view
@@ -8,11 +8,20 @@ #endif  module Text.RE.TDFA.ByteString.Lazy-  ( (*=~)+  (+  -- * Tutorial+  -- $tutorial++  -- * The Match Operators+    (*=~)   , (?=~)   , (=~)   , (=~~)+  -- * The Toolkit+  -- $toolkit   , module Text.RE+  -- * The 'RE' Type+  -- $re   , module Text.RE.TDFA.RE   ) where @@ -30,13 +39,13 @@       -> Matches LBS.ByteString (*=~) bs rex = addCaptureNamesToMatches (reCaptureNames rex) $ match (reRegex rex) bs --- | find first matches in text+-- | find first match in text (?=~) :: LBS.ByteString       -> RE       -> Match LBS.ByteString (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs --- | regex-base polymorphic match operator+-- | the regex-base polymorphic match operator (=~) :: ( RegexContext TDFA.Regex LBS.ByteString a         , RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption String         )@@ -45,7 +54,7 @@      -> a (=~) bs rex = match (reRegex rex) bs --- | regex-base monadic, polymorphic match operator+-- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m          , RegexContext TDFA.Regex LBS.ByteString a          , RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption String@@ -59,3 +68,18 @@   matchOnce   = flip (?=~)   matchMany   = flip (*=~)   regexSource = reSource++-- $tutorial+-- We have a regex tutorial at <http://tutorial.regex.uk>. These API+-- docs are mainly for reference.++-- $toolkit+--+-- Beyond the above match operators and the regular expression type+-- below, "Text.RE" contains the toolkit for replacing captures,+-- specifying options, etc.++-- $re+--+-- "Text.RE.TDFA.RE" contains the toolkit specific to the 'RE' type,+-- the type generated by the gegex compiler.
Text/RE/TDFA/RE.hs view
@@ -106,17 +106,14 @@ instance IsOption SimpleRegexOptions RE CompOption ExecOption where   makeOptions    = unpackSimpleRegexOptions -instance IsOption Mode        RE CompOption ExecOption where-  makeOptions md = Options md prelude def_comp_option def_exec_option- instance IsOption (Macros RE) RE CompOption ExecOption where-  makeOptions ms = Options minBound ms def_comp_option def_exec_option+  makeOptions ms = Options ms def_comp_option def_exec_option  instance IsOption CompOption  RE CompOption ExecOption where-  makeOptions co = Options minBound prelude co def_exec_option+  makeOptions co = Options prelude co def_exec_option  instance IsOption ExecOption  RE CompOption ExecOption where-  makeOptions eo = Options minBound prelude def_comp_option eo+  makeOptions eo = Options prelude def_comp_option eo  instance IsOption Options     RE CompOption ExecOption where   makeOptions    = id@@ -125,13 +122,13 @@   makeOptions _  = unpackSimpleRegexOptions minBound  def_comp_option :: CompOption-def_comp_option = _options_comp defaultOptions+def_comp_option = optionsComp defaultOptions  def_exec_option :: ExecOption-def_exec_option = _options_exec defaultOptions+def_exec_option = optionsExec defaultOptions  noPreludeOptions :: Options-noPreludeOptions = defaultOptions { _options_macs = emptyMacros }+noPreludeOptions = defaultOptions { optionsMacs = emptyMacros }  defaultOptions :: Options defaultOptions = makeOptions (minBound::SimpleRegexOptions)@@ -139,10 +136,9 @@ unpackSimpleRegexOptions :: SimpleRegexOptions -> Options unpackSimpleRegexOptions sro =   Options-    { _options_mode = minBound-    , _options_macs = prelude-    , _options_comp = comp-    , _options_exec = defaultExecOpt+    { optionsMacs = prelude+    , optionsComp = comp+    , optionsExec = defaultExecOpt     }   where     comp = defaultCompOpt@@ -217,9 +213,9 @@               -> m (CaptureNames,Regex) compileRegex' Options{..} s0 = do     (cnms,s2) <- either fail return $ extractNamedCaptures s1-    (,) cnms <$> makeRegexOptsM _options_comp _options_exec s2+    (,) cnms <$> makeRegexOptsM optionsComp optionsExec s2   where-    s1 = expandMacros reSource _options_mode _options_macs s0+    s1 = expandMacros reSource optionsMacs s0  prelude :: Macros RE prelude = runIdentity $ preludeMacros mk TDFA ExclCaptures
Text/RE/TDFA/Sequence.hs view
@@ -8,11 +8,20 @@ #endif  module Text.RE.TDFA.Sequence-  ( (*=~)+  (+  -- * Tutorial+  -- $tutorial++  -- * The Match Operators+    (*=~)   , (?=~)   , (=~)   , (=~~)+  -- * The Toolkit+  -- $toolkit   , module Text.RE+  -- * The 'RE' Type+  -- $re   , module Text.RE.TDFA.RE   ) where @@ -30,13 +39,13 @@       -> Matches (S.Seq Char) (*=~) bs rex = addCaptureNamesToMatches (reCaptureNames rex) $ match (reRegex rex) bs --- | find first matches in text+-- | find first match in text (?=~) :: (S.Seq Char)       -> RE       -> Match (S.Seq Char) (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs --- | regex-base polymorphic match operator+-- | the regex-base polymorphic match operator (=~) :: ( RegexContext TDFA.Regex (S.Seq Char) a         , RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption String         )@@ -45,7 +54,7 @@      -> a (=~) bs rex = match (reRegex rex) bs --- | regex-base monadic, polymorphic match operator+-- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m          , RegexContext TDFA.Regex (S.Seq Char) a          , RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption String@@ -59,3 +68,18 @@   matchOnce   = flip (?=~)   matchMany   = flip (*=~)   regexSource = reSource++-- $tutorial+-- We have a regex tutorial at <http://tutorial.regex.uk>. These API+-- docs are mainly for reference.++-- $toolkit+--+-- Beyond the above match operators and the regular expression type+-- below, "Text.RE" contains the toolkit for replacing captures,+-- specifying options, etc.++-- $re+--+-- "Text.RE.TDFA.RE" contains the toolkit specific to the 'RE' type,+-- the type generated by the gegex compiler.
Text/RE/TDFA/String.hs view
@@ -8,11 +8,20 @@ #endif  module Text.RE.TDFA.String-  ( (*=~)+  (+  -- * Tutorial+  -- $tutorial++  -- * The Match Operators+    (*=~)   , (?=~)   , (=~)   , (=~~)+  -- * The Toolkit+  -- $toolkit   , module Text.RE+  -- * The 'RE' Type+  -- $re   , module Text.RE.TDFA.RE   ) where @@ -30,13 +39,13 @@       -> Matches String (*=~) bs rex = addCaptureNamesToMatches (reCaptureNames rex) $ match (reRegex rex) bs --- | find first matches in text+-- | find first match in text (?=~) :: String       -> RE       -> Match String (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs --- | regex-base polymorphic match operator+-- | the regex-base polymorphic match operator (=~) :: ( RegexContext TDFA.Regex String a         , RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption String         )@@ -45,7 +54,7 @@      -> a (=~) bs rex = match (reRegex rex) bs --- | regex-base monadic, polymorphic match operator+-- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m          , RegexContext TDFA.Regex String a          , RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption String@@ -59,3 +68,18 @@   matchOnce   = flip (?=~)   matchMany   = flip (*=~)   regexSource = reSource++-- $tutorial+-- We have a regex tutorial at <http://tutorial.regex.uk>. These API+-- docs are mainly for reference.++-- $toolkit+--+-- Beyond the above match operators and the regular expression type+-- below, "Text.RE" contains the toolkit for replacing captures,+-- specifying options, etc.++-- $re+--+-- "Text.RE.TDFA.RE" contains the toolkit specific to the 'RE' type,+-- the type generated by the gegex compiler.
Text/RE/TDFA/Text.hs view
@@ -8,11 +8,20 @@ #endif  module Text.RE.TDFA.Text-  ( (*=~)+  (+  -- * Tutorial+  -- $tutorial++  -- * The Match Operators+    (*=~)   , (?=~)   , (=~)   , (=~~)+  -- * The Toolkit+  -- $toolkit   , module Text.RE+  -- * The 'RE' Type+  -- $re   , module Text.RE.TDFA.RE   ) where @@ -30,13 +39,13 @@       -> Matches T.Text (*=~) bs rex = addCaptureNamesToMatches (reCaptureNames rex) $ match (reRegex rex) bs --- | find first matches in text+-- | find first match in text (?=~) :: T.Text       -> RE       -> Match T.Text (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs --- | regex-base polymorphic match operator+-- | the regex-base polymorphic match operator (=~) :: ( RegexContext TDFA.Regex T.Text a         , RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption String         )@@ -45,7 +54,7 @@      -> a (=~) bs rex = match (reRegex rex) bs --- | regex-base monadic, polymorphic match operator+-- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m          , RegexContext TDFA.Regex T.Text a          , RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption String@@ -59,3 +68,18 @@   matchOnce   = flip (?=~)   matchMany   = flip (*=~)   regexSource = reSource++-- $tutorial+-- We have a regex tutorial at <http://tutorial.regex.uk>. These API+-- docs are mainly for reference.++-- $toolkit+--+-- Beyond the above match operators and the regular expression type+-- below, "Text.RE" contains the toolkit for replacing captures,+-- specifying options, etc.++-- $re+--+-- "Text.RE.TDFA.RE" contains the toolkit specific to the 'RE' type,+-- the type generated by the gegex compiler.
Text/RE/TDFA/Text/Lazy.hs view
@@ -8,11 +8,20 @@ #endif  module Text.RE.TDFA.Text.Lazy-  ( (*=~)+  (+  -- * Tutorial+  -- $tutorial++  -- * The Match Operators+    (*=~)   , (?=~)   , (=~)   , (=~~)+  -- * The Toolkit+  -- $toolkit   , module Text.RE+  -- * The 'RE' Type+  -- $re   , module Text.RE.TDFA.RE   ) where @@ -30,13 +39,13 @@       -> Matches TL.Text (*=~) bs rex = addCaptureNamesToMatches (reCaptureNames rex) $ match (reRegex rex) bs --- | find first matches in text+-- | find first match in text (?=~) :: TL.Text       -> RE       -> Match TL.Text (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs --- | regex-base polymorphic match operator+-- | the regex-base polymorphic match operator (=~) :: ( RegexContext TDFA.Regex TL.Text a         , RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption String         )@@ -45,7 +54,7 @@      -> a (=~) bs rex = match (reRegex rex) bs --- | regex-base monadic, polymorphic match operator+-- | the regex-base monadic, polymorphic match operator (=~~) :: ( Monad m          , RegexContext TDFA.Regex TL.Text a          , RegexMaker   TDFA.Regex TDFA.CompOption TDFA.ExecOption String@@ -59,3 +68,18 @@   matchOnce   = flip (?=~)   matchMany   = flip (*=~)   regexSource = reSource++-- $tutorial+-- We have a regex tutorial at <http://tutorial.regex.uk>. These API+-- docs are mainly for reference.++-- $toolkit+--+-- Beyond the above match operators and the regular expression type+-- below, "Text.RE" contains the toolkit for replacing captures,+-- specifying options, etc.++-- $re+--+-- "Text.RE.TDFA.RE" contains the toolkit specific to the 'RE' type,+-- the type generated by the gegex compiler.
Text/RE/TestBench.lhs view
@@ -142,7 +142,7 @@   []    -> return True   fails -> do     putStrLn $ lab' ++ " has failing tests for these macros: "-    putStr   $ unlines $ [ "  "++_MacroID mid | mid<-fails ]+    putStr   $ unlines $ [ "  "++getMacroID mid | mid<-fails ]     putStrLn $ "The whole table:"     putStrLn $ "========================================================"     putStr   $ formatMacroTable rty m_env@@ -237,7 +237,7 @@           [ln] -> (,) ln []           lns_ -> (,) "" lns_ -    oops = error $ _MacroID mid ++ ": macro not defined in this environment"+    oops = error $ getMacroID mid ++ ": macro not defined in this environment" \end{code}  \begin{code}@@ -246,7 +246,7 @@                    -> MacroEnv                    -> String formatMacroSources rty wc env = unlines $-    [ printf "%-20s : %s" (_MacroID mid) $ formatMacroSource rty wc env mid+    [ printf "%-20s : %s" (getMacroID mid) $ formatMacroSource rty wc env mid         | mid <- L.sort $ HML.keys env         ] \end{code}@@ -260,7 +260,7 @@ formatMacroSource rty wc env mid =     mdRegexSource rty wc env $ fromMaybe oops $ HML.lookup mid env   where-    oops = error $ "formatMacroSource: not found: " ++ _MacroID mid+    oops = error $ "formatMacroSource: not found: " ++ getMacroID mid \end{code}  @@ -317,7 +317,7 @@                 -> [String] macro_attribute rty mid MacroDescriptor{..} c =     case c of-      C_name          -> [_MacroID mid]+      C_name          -> [getMacroID mid]       C_caps          -> [show $ min_captures rty $ scan_re _md_source]       C_regex         -> [regexSource rty ExclCaptures _md_source]       C_examples      -> _md_samples@@ -558,7 +558,7 @@     TestResult $       printf "%-20s [%s %s] : %s (%s)" mid_s neg_s rty_s msg tst   where-    mid_s = _MacroID mid+    mid_s = getMacroID mid     neg_s = if is_neg then "-ve" else "+ve" :: String     rty_s = show rty \end{code}
Text/RE/Tools/Grep.lhs view
@@ -23,8 +23,8 @@  data Line =   Line-    { _ln_no      :: LineNo-    , _ln_matches :: Matches LBS.ByteString+    { getLineNumber  :: LineNo+    , getLineMatches :: Matches LBS.ByteString     }   deriving (Show) @@ -54,9 +54,9 @@ report = unlines . map fmt . linesMatched   where     fmt Line{..} =-      printf "%05d %s" (getLineNo _ln_no) $-          LBS.unpack $ matchesSource _ln_matches+      printf "%05d %s" (getLineNo getLineNumber) $+          LBS.unpack $ matchesSource getLineMatches  linesMatched :: [Line] -> [Line]-linesMatched = filter $ anyMatches . _ln_matches+linesMatched = filter $ anyMatches . getLineMatches \end{code}
Text/RE/Tools/Lex.lhs view
@@ -20,7 +20,7 @@       -> [t] alex' mo al t_err = loop   where-    loop s = case length_ s == 0 of+    loop s = case lengthE s == 0 of       True  -> []       False -> choose al s 
changelog view
@@ -1,9 +1,16 @@ -*-change-log-*- +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+  * Integrate the regex blog+  * Better presentation of ghci tryouts in the Tutorial+  * Various minor README upgrades and fixes+ 0.2.0.4 Chris Dornan <chris.dornan@irisconnect.co.uk> 2017-02-22   * Repair re-gen-modules-test for Windows -0.2.0.4 Chris Dornan <chris.dornan@irisconnect.co.uk> 2017-02-21+0.2.0.3 Chris Dornan <chris.dornan@irisconnect.co.uk> 2017-02-21   * README/index layout tweak  0.2.0.2 Chris Dornan <chris.dornan@irisconnect.co.uk> 2017-02-21
regex.cabal view
@@ -1,5 +1,5 @@ Name:                   regex-Version:                0.2.0.4+Version:                0.3.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.2.0.4+    Tag:                0.3.0.0   @@ -76,6 +76,7 @@     GHC-Options:       -Wall       -fwarn-tabs+      -Wwarn      Build-depends:         array                >= 0.4