packages feed

regex-with-pcre 0.10.0.3 → 0.11.0.0

raw patch · 26 files changed

+931/−931 lines, 26 filesdep ~regexPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: regex

API changes (from Hackage documentation)

- Text.RE.PCRE.ByteString: instance Text.RE.Types.IsRegex.IsRegex Text.RE.PCRE.RE.RE Data.ByteString.Internal.ByteString
- Text.RE.PCRE.ByteString.Lazy: instance Text.RE.Types.IsRegex.IsRegex Text.RE.PCRE.RE.RE Data.ByteString.Lazy.Internal.ByteString
- Text.RE.PCRE.RE: compileRegex :: (Functor m, Monad m) => String -> m RE
- Text.RE.PCRE.RE: compileRegexWith :: (Functor m, Monad m) => SimpleREOptions -> String -> m RE
- Text.RE.PCRE.RE: compileRegexWithOptions :: (IsOption o RE CompOption ExecOption, Functor m, Monad m) => o -> String -> m RE
- Text.RE.PCRE.RE: compileSearchReplace :: (Monad m, Functor m, IsRegex RE s) => String -> String -> m (SearchReplace RE s)
- Text.RE.PCRE.RE: compileSearchReplaceWith :: (Monad m, Functor m, IsRegex RE s) => SimpleREOptions -> String -> String -> m (SearchReplace RE s)
- Text.RE.PCRE.RE: compileSearchReplaceWithREOptions :: (Monad m, Functor m, IsRegex RE s) => REOptions -> String -> String -> m (SearchReplace RE s)
- Text.RE.PCRE.RE: cp :: QuasiQuoter
- Text.RE.PCRE.RE: data RE
- Text.RE.PCRE.RE: defaultREOptions :: REOptions
- Text.RE.PCRE.RE: escape :: (Functor m, Monad m) => (String -> String) -> String -> m RE
- Text.RE.PCRE.RE: escapeREString :: String -> String
- Text.RE.PCRE.RE: escapeWith :: (Functor m, Monad m) => SimpleREOptions -> (String -> String) -> String -> m RE
- Text.RE.PCRE.RE: escapeWithOptions :: (IsOption o RE CompOption ExecOption, Functor m, Monad m) => o -> (String -> String) -> String -> m RE
- Text.RE.PCRE.RE: instance Text.RE.Types.REOptions.IsOption () Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.PCRE.RE: instance Text.RE.Types.REOptions.IsOption (Text.RE.Types.REOptions.Macros Text.RE.PCRE.RE.RE) Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.PCRE.RE: instance Text.RE.Types.REOptions.IsOption Text.RE.PCRE.RE.REOptions Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.PCRE.RE: instance Text.RE.Types.REOptions.IsOption Text.RE.Types.REOptions.SimpleREOptions Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.PCRE.RE: instance Text.RE.Types.REOptions.IsOption Text.Regex.PCRE.Wrap.CompOption Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.PCRE.RE: instance Text.RE.Types.REOptions.IsOption Text.Regex.PCRE.Wrap.ExecOption Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.PCRE.RE: noPreludeREOptions :: REOptions
- Text.RE.PCRE.RE: prelude :: Macros RE
- Text.RE.PCRE.RE: preludeEnv :: MacroEnv
- Text.RE.PCRE.RE: preludeSource :: PreludeMacro -> String
- Text.RE.PCRE.RE: preludeSources :: String
- Text.RE.PCRE.RE: preludeSummary :: PreludeMacro -> String
- Text.RE.PCRE.RE: preludeTable :: String
- Text.RE.PCRE.RE: preludeTestsFailing :: [MacroID]
- Text.RE.PCRE.RE: re :: QuasiQuoter
- Text.RE.PCRE.RE: reBI :: QuasiQuoter
- Text.RE.PCRE.RE: reBS :: QuasiQuoter
- Text.RE.PCRE.RE: reBlockInsensitive :: QuasiQuoter
- Text.RE.PCRE.RE: reBlockSensitive :: QuasiQuoter
- Text.RE.PCRE.RE: reCaptureNames :: RE -> CaptureNames
- Text.RE.PCRE.RE: reMI :: QuasiQuoter
- Text.RE.PCRE.RE: reMS :: QuasiQuoter
- Text.RE.PCRE.RE: reMultilineInsensitive :: QuasiQuoter
- Text.RE.PCRE.RE: reMultilineSensitive :: QuasiQuoter
- Text.RE.PCRE.RE: reOptions :: RE -> REOptions
- Text.RE.PCRE.RE: reRegex :: RE -> Regex
- Text.RE.PCRE.RE: reSource :: RE -> String
- Text.RE.PCRE.RE: re_ :: QuasiQuoter
- Text.RE.PCRE.RE: regexType :: RegexType
- Text.RE.PCRE.RE: type REOptions = REOptions_ RE CompOption ExecOption
- Text.RE.PCRE.RE: unpackSimpleREOptions :: SimpleREOptions -> REOptions
- Text.RE.PCRE.Sequence: instance Text.RE.Types.IsRegex.IsRegex Text.RE.PCRE.RE.RE (Data.Sequence.Seq GHC.Types.Char)
- Text.RE.PCRE.String: instance Text.RE.Types.IsRegex.IsRegex Text.RE.PCRE.RE.RE GHC.Base.String
+ Text.RE.PCRE.ByteString: instance Text.RE.IsRegex.IsRegex Text.RE.ZeInternals.PCRE.RE Data.ByteString.Internal.ByteString
+ Text.RE.PCRE.ByteString.Lazy: instance Text.RE.IsRegex.IsRegex Text.RE.ZeInternals.PCRE.RE Data.ByteString.Lazy.Internal.ByteString
+ Text.RE.PCRE.Sequence: instance Text.RE.IsRegex.IsRegex Text.RE.ZeInternals.PCRE.RE (Data.Sequence.Seq GHC.Types.Char)
+ Text.RE.PCRE.String: instance Text.RE.IsRegex.IsRegex Text.RE.ZeInternals.PCRE.RE GHC.Base.String
+ Text.RE.ZeInternals.PCRE: compileRegex :: (Functor m, Monad m) => String -> m RE
+ Text.RE.ZeInternals.PCRE: compileRegexWith :: (Functor m, Monad m) => SimpleREOptions -> String -> m RE
+ Text.RE.ZeInternals.PCRE: compileRegexWithOptions :: (IsOption o RE CompOption ExecOption, Functor m, Monad m) => o -> String -> m RE
+ Text.RE.ZeInternals.PCRE: compileSearchReplace :: (Monad m, Functor m, IsRegex RE s) => String -> String -> m (SearchReplace RE s)
+ Text.RE.ZeInternals.PCRE: compileSearchReplaceWith :: (Monad m, Functor m, IsRegex RE s) => SimpleREOptions -> String -> String -> m (SearchReplace RE s)
+ Text.RE.ZeInternals.PCRE: compileSearchReplaceWithREOptions :: (Monad m, Functor m, IsRegex RE s) => REOptions -> String -> String -> m (SearchReplace RE s)
+ Text.RE.ZeInternals.PCRE: cp :: QuasiQuoter
+ Text.RE.ZeInternals.PCRE: data RE
+ Text.RE.ZeInternals.PCRE: defaultREOptions :: REOptions
+ Text.RE.ZeInternals.PCRE: escape :: (Functor m, Monad m) => (String -> String) -> String -> m RE
+ Text.RE.ZeInternals.PCRE: escapeREString :: String -> String
+ Text.RE.ZeInternals.PCRE: escapeWith :: (Functor m, Monad m) => SimpleREOptions -> (String -> String) -> String -> m RE
+ Text.RE.ZeInternals.PCRE: escapeWithOptions :: (IsOption o RE CompOption ExecOption, Functor m, Monad m) => o -> (String -> String) -> String -> m RE
+ Text.RE.ZeInternals.PCRE: instance Text.RE.REOptions.IsOption () Text.RE.ZeInternals.PCRE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
+ Text.RE.ZeInternals.PCRE: instance Text.RE.REOptions.IsOption (Text.RE.REOptions.Macros Text.RE.ZeInternals.PCRE.RE) Text.RE.ZeInternals.PCRE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
+ Text.RE.ZeInternals.PCRE: instance Text.RE.REOptions.IsOption Text.RE.REOptions.SimpleREOptions Text.RE.ZeInternals.PCRE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
+ Text.RE.ZeInternals.PCRE: instance Text.RE.REOptions.IsOption Text.RE.ZeInternals.PCRE.REOptions Text.RE.ZeInternals.PCRE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
+ Text.RE.ZeInternals.PCRE: instance Text.RE.REOptions.IsOption Text.Regex.PCRE.Wrap.CompOption Text.RE.ZeInternals.PCRE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
+ Text.RE.ZeInternals.PCRE: instance Text.RE.REOptions.IsOption Text.Regex.PCRE.Wrap.ExecOption Text.RE.ZeInternals.PCRE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
+ Text.RE.ZeInternals.PCRE: noPreludeREOptions :: REOptions
+ Text.RE.ZeInternals.PCRE: prelude :: Macros RE
+ Text.RE.ZeInternals.PCRE: preludeEnv :: MacroEnv
+ Text.RE.ZeInternals.PCRE: preludeSource :: PreludeMacro -> String
+ Text.RE.ZeInternals.PCRE: preludeSources :: String
+ Text.RE.ZeInternals.PCRE: preludeSummary :: PreludeMacro -> String
+ Text.RE.ZeInternals.PCRE: preludeTable :: String
+ Text.RE.ZeInternals.PCRE: preludeTestsFailing :: [MacroID]
+ Text.RE.ZeInternals.PCRE: re :: QuasiQuoter
+ Text.RE.ZeInternals.PCRE: reBI :: QuasiQuoter
+ Text.RE.ZeInternals.PCRE: reBS :: QuasiQuoter
+ Text.RE.ZeInternals.PCRE: reBlockInsensitive :: QuasiQuoter
+ Text.RE.ZeInternals.PCRE: reBlockSensitive :: QuasiQuoter
+ Text.RE.ZeInternals.PCRE: reCaptureNames :: RE -> CaptureNames
+ Text.RE.ZeInternals.PCRE: reMI :: QuasiQuoter
+ Text.RE.ZeInternals.PCRE: reMS :: QuasiQuoter
+ Text.RE.ZeInternals.PCRE: reMultilineInsensitive :: QuasiQuoter
+ Text.RE.ZeInternals.PCRE: reMultilineSensitive :: QuasiQuoter
+ Text.RE.ZeInternals.PCRE: reOptions :: RE -> REOptions
+ Text.RE.ZeInternals.PCRE: reRegex :: RE -> Regex
+ Text.RE.ZeInternals.PCRE: reSource :: RE -> String
+ Text.RE.ZeInternals.PCRE: re_ :: QuasiQuoter
+ Text.RE.ZeInternals.PCRE: regexType :: RegexType
+ Text.RE.ZeInternals.PCRE: type REOptions = REOptions_ RE CompOption ExecOption
+ Text.RE.ZeInternals.PCRE: unpackSimpleREOptions :: SimpleREOptions -> REOptions

Files

README.markdown view
@@ -68,6 +68,8 @@      ☒  2017-03-28  v0.10.0.3 [Upgrade to LTS 8.6 and Improve Haddocks for Text.RE.{TDFA,PCRE}](https://github.com/iconnect/regex/milestone/13) +    ☒  2017-03-29  v0.11.0.0 [Simplify the API](https://github.com/iconnect/regex/milestone/14)+     ☐  2017-03-31  v1.0.0.0  [First stable release](https://github.com/iconnect/regex/milestone/3)      ☐  2017-08-31  v2.0.0.0  [Fast text replacement with benchmarks](https://github.com/iconnect/regex/milestone/4)
− Text/RE/Internal/QQ.hs
@@ -1,29 +0,0 @@-{-# LANGUAGE DeriveDataTypeable         #-}--module Text.RE.Internal.QQ where--import           Control.Exception-import           Data.Typeable-import           Language.Haskell.TH.Quote----- | used to throw an exception reporting an abuse of a quasi quoter-data QQFailure =-  QQFailure-    { _qqf_context   :: String  -- ^ in what context was the quasi quoter used-    , _qqf_component :: String  -- ^ how was the quasi quoter being abused-    }-  deriving (Show,Typeable)--instance Exception QQFailure where---- | a quasi quoter that can be used in no context (to be extended with--- the appropriate quasi quoter parser)-qq0 :: String -> QuasiQuoter-qq0 ctx =-  QuasiQuoter-    { quoteExp  = const $ throw $ QQFailure ctx "expression"-    , quotePat  = const $ throw $ QQFailure ctx "pattern"-    , quoteType = const $ throw $ QQFailure ctx "type"-    , quoteDec  = const $ throw $ QQFailure ctx "declaration"-    }
− Text/RE/Internal/SearchReplace.hs
@@ -1,84 +0,0 @@-{-# LANGUAGE NoImplicitPrelude          #-}-{-# LANGUAGE RecordWildCards            #-}-{-# LANGUAGE CPP                        #-}-#if __GLASGOW_HASKELL__ >= 800-{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}-{-# LANGUAGE TemplateHaskellQuotes      #-}-#else-{-# LANGUAGE QuasiQuotes                #-}-{-# LANGUAGE TemplateHaskell            #-}-#endif-{-# OPTIONS_GHC -fno-warn-orphans       #-}--module Text.RE.Internal.SearchReplace-  ( unsafeCompileSearchReplace_-  , compileSearchReplace_-  , compileSearchAndReplace_-  ) where--import qualified Data.HashMap.Strict            as HMS-import           Prelude.Compat-import           Text.RE.Internal.NamedCaptures-import           Text.RE.Types.Capture-import           Text.RE.Types.CaptureID-import           Text.RE.Types.Matches-import           Text.RE.Types.Replace-import           Text.RE.Types.SearchReplace-import qualified Text.Regex.TDFA                as TDFA----- | warapper on 'compileSearchReplace_' that will generate an error--- if any compilation errors are found-unsafeCompileSearchReplace_ :: (String->s)-                            -> (String->Either String re)-                            -> String-                            -> SearchReplace re s-unsafeCompileSearchReplace_ pk cf = either err id . compileSearchReplace_ pk cf-  where-    err msg = error $ "unsafeCompileSearchReplace_: " ++ msg---- | compile a SearchReplace template generating errors if the RE or--- the template are not well formed -- all capture references being checked-compileSearchReplace_ :: (Monad m,Functor m)-                      => (String->s)-                      -> (String->Either String re)-                      -> String-                      -> m (SearchReplace re s)-compileSearchReplace_ pack compile_re sr_tpl = either fail return $ do-    case mainCaptures $ sr_tpl $=~ "///" of-      [cap] ->-        compileSearchAndReplace_ pack compile_re-                      (capturePrefix cap) (captureSuffix cap)-      _ -> Left $ "bad search-replace template syntax: " ++ sr_tpl---- | compile 'SearcgReplace' from two strings containing the RE--- and the replacement template-compileSearchAndReplace_ :: (Monad m,Functor m)-                         => (String->s)-                         -> (String->Either String re)-                         -> String-                         -> String-                         -> m (SearchReplace re s)-compileSearchAndReplace_ pack compile_re re_s tpl = either fail return $ do-    re           <- compile_re re_s-    ((n,cnms),_) <- extractNamedCaptures re_s-    mapM_ (check n cnms) $ templateCaptures id tpl-    return $ SearchReplace re $ pack tpl-  where-    check :: Int -> CaptureNames -> CaptureID -> Either String ()-    check n cnms cid = case cid of-      IsCaptureOrdinal co -> check_co n    co-      IsCaptureName    cn -> check_cn cnms cn--    check_co n (CaptureOrdinal i) = case i <= n of-      True  -> return ()-      False -> Left $ "capture ordinal out of range: " ++-                                      show i ++ " >= " ++ show n--    check_cn cnms cnm = case cnm `HMS.member` cnms of-      True  -> return ()-      False -> Left $ "capture name not defined: " ++-                                      show (getCaptureName cnm)--($=~) :: String -> String -> Matches String-($=~) = (TDFA.=~)
− Text/RE/Internal/SearchReplace/PCRE.hs
@@ -1,54 +0,0 @@-{-# LANGUAGE NoImplicitPrelude          #-}-{-# LANGUAGE CPP                        #-}-#if __GLASGOW_HASKELL__ >= 800-{-# LANGUAGE TemplateHaskellQuotes      #-}-#else-{-# LANGUAGE QuasiQuotes                #-}-{-# LANGUAGE TemplateHaskell            #-}-#endif--module Text.RE.Internal.SearchReplace.PCRE-  ( ed-  , edMS-  , edMI-  , edBS-  , edBI-  , edMultilineSensitive-  , edMultilineInsensitive-  , edBlockSensitive-  , edBlockInsensitive-  , ed_-  ) where--import           Language.Haskell.TH-import           Language.Haskell.TH.Quote-import           Prelude.Compat-import           Text.RE.Internal.SearchReplace.PCREEdPrime-import           Text.RE.Types.REOptions----- | the @[ed| ... /// ... |]@ quasi quoters-ed-  , edMS-  , edMI-  , edBS-  , edBI-  , edMultilineSensitive-  , edMultilineInsensitive-  , edBlockSensitive-  , edBlockInsensitive-  , ed_ :: QuasiQuoter--ed                       = ed' cast $ Just minBound-edMS                     = edMultilineSensitive-edMI                     = edMultilineInsensitive-edBS                     = edBlockSensitive-edBI                     = edBlockInsensitive-edMultilineSensitive     = ed' cast $ Just  MultilineSensitive-edMultilineInsensitive   = ed' cast $ Just  MultilineInsensitive-edBlockSensitive         = ed' cast $ Just  BlockSensitive-edBlockInsensitive       = ed' cast $ Just  BlockInsensitive-ed_                      = ed' cast   Nothing--cast :: Q Exp-cast = [|id|]
− Text/RE/Internal/SearchReplace/PCRE/ByteString.hs
@@ -1,58 +0,0 @@-{-# LANGUAGE CPP                        #-}-#if __GLASGOW_HASKELL__ >= 800-{-# LANGUAGE TemplateHaskellQuotes      #-}-#else-{-# LANGUAGE QuasiQuotes                #-}-{-# LANGUAGE TemplateHaskell            #-}-#endif--module Text.RE.Internal.SearchReplace.PCRE.ByteString-  ( ed-  , edMS-  , edMI-  , edBS-  , edBI-  , edMultilineSensitive-  , edMultilineInsensitive-  , edBlockSensitive-  , edBlockInsensitive-  , ed_-  ) where--import qualified Data.ByteString.Char8         as B-import           Language.Haskell.TH-import           Language.Haskell.TH.Quote-import           Text.RE.PCRE.RE-import           Text.RE.Internal.SearchReplace.PCREEdPrime-import           Text.RE.SearchReplace-import           Text.RE.Types.REOptions----- | the @[ed| ... /// ... |]@ quasi quoters-ed-  , edMS-  , edMI-  , edBS-  , edBI-  , edMultilineSensitive-  , edMultilineInsensitive-  , edBlockSensitive-  , edBlockInsensitive-  , ed_ :: QuasiQuoter--ed                       = ed' sr_cast $ Just minBound-edMS                     = edMultilineSensitive-edMI                     = edMultilineInsensitive-edBS                     = edBlockSensitive-edBI                     = edBlockInsensitive-edMultilineSensitive     = ed' sr_cast $ Just  MultilineSensitive-edMultilineInsensitive   = ed' sr_cast $ Just  MultilineInsensitive-edBlockSensitive         = ed' sr_cast $ Just  BlockSensitive-edBlockInsensitive       = ed' sr_cast $ Just  BlockInsensitive-ed_                      = ed' fn_cast   Nothing--sr_cast :: Q Exp-sr_cast = [|\x -> x :: SearchReplace RE B.ByteString|]--fn_cast :: Q Exp-fn_cast = [|\x -> x :: SimpleREOptions -> SearchReplace RE B.ByteString|]
− Text/RE/Internal/SearchReplace/PCRE/ByteString/Lazy.hs
@@ -1,58 +0,0 @@-{-# LANGUAGE CPP                        #-}-#if __GLASGOW_HASKELL__ >= 800-{-# LANGUAGE TemplateHaskellQuotes      #-}-#else-{-# LANGUAGE QuasiQuotes                #-}-{-# LANGUAGE TemplateHaskell            #-}-#endif--module Text.RE.Internal.SearchReplace.PCRE.ByteString.Lazy-  ( ed-  , edMS-  , edMI-  , edBS-  , edBI-  , edMultilineSensitive-  , edMultilineInsensitive-  , edBlockSensitive-  , edBlockInsensitive-  , ed_-  ) where--import qualified Data.ByteString.Lazy.Char8    as LBS-import           Language.Haskell.TH-import           Language.Haskell.TH.Quote-import           Text.RE.PCRE.RE-import           Text.RE.Internal.SearchReplace.PCREEdPrime-import           Text.RE.SearchReplace-import           Text.RE.Types.REOptions----- | the @[ed| ... /// ... |]@ quasi quoters-ed-  , edMS-  , edMI-  , edBS-  , edBI-  , edMultilineSensitive-  , edMultilineInsensitive-  , edBlockSensitive-  , edBlockInsensitive-  , ed_ :: QuasiQuoter--ed                       = ed' sr_cast $ Just minBound-edMS                     = edMultilineSensitive-edMI                     = edMultilineInsensitive-edBS                     = edBlockSensitive-edBI                     = edBlockInsensitive-edMultilineSensitive     = ed' sr_cast $ Just  MultilineSensitive-edMultilineInsensitive   = ed' sr_cast $ Just  MultilineInsensitive-edBlockSensitive         = ed' sr_cast $ Just  BlockSensitive-edBlockInsensitive       = ed' sr_cast $ Just  BlockInsensitive-ed_                      = ed' fn_cast   Nothing--sr_cast :: Q Exp-sr_cast = [|\x -> x :: SearchReplace RE LBS.ByteString|]--fn_cast :: Q Exp-fn_cast = [|\x -> x :: SimpleREOptions -> SearchReplace RE LBS.ByteString|]
− Text/RE/Internal/SearchReplace/PCRE/Sequence.hs
@@ -1,58 +0,0 @@-{-# LANGUAGE CPP                        #-}-#if __GLASGOW_HASKELL__ >= 800-{-# LANGUAGE TemplateHaskellQuotes      #-}-#else-{-# LANGUAGE QuasiQuotes                #-}-{-# LANGUAGE TemplateHaskell            #-}-#endif--module Text.RE.Internal.SearchReplace.PCRE.Sequence-  ( ed-  , edMS-  , edMI-  , edBS-  , edBI-  , edMultilineSensitive-  , edMultilineInsensitive-  , edBlockSensitive-  , edBlockInsensitive-  , ed_-  ) where--import qualified Data.Sequence                 as S-import           Language.Haskell.TH-import           Language.Haskell.TH.Quote-import           Text.RE.PCRE.RE-import           Text.RE.Internal.SearchReplace.PCREEdPrime-import           Text.RE.SearchReplace-import           Text.RE.Types.REOptions----- | the @[ed| ... /// ... |]@ quasi quoters-ed-  , edMS-  , edMI-  , edBS-  , edBI-  , edMultilineSensitive-  , edMultilineInsensitive-  , edBlockSensitive-  , edBlockInsensitive-  , ed_ :: QuasiQuoter--ed                       = ed' sr_cast $ Just minBound-edMS                     = edMultilineSensitive-edMI                     = edMultilineInsensitive-edBS                     = edBlockSensitive-edBI                     = edBlockInsensitive-edMultilineSensitive     = ed' sr_cast $ Just  MultilineSensitive-edMultilineInsensitive   = ed' sr_cast $ Just  MultilineInsensitive-edBlockSensitive         = ed' sr_cast $ Just  BlockSensitive-edBlockInsensitive       = ed' sr_cast $ Just  BlockInsensitive-ed_                      = ed' fn_cast   Nothing--sr_cast :: Q Exp-sr_cast = [|\x -> x :: SearchReplace RE (S.Seq Char)|]--fn_cast :: Q Exp-fn_cast = [|\x -> x :: SimpleREOptions -> SearchReplace RE (S.Seq Char)|]
− Text/RE/Internal/SearchReplace/PCRE/String.hs
@@ -1,58 +0,0 @@-{-# LANGUAGE CPP                        #-}-#if __GLASGOW_HASKELL__ >= 800-{-# LANGUAGE TemplateHaskellQuotes      #-}-#else-{-# LANGUAGE QuasiQuotes                #-}-{-# LANGUAGE TemplateHaskell            #-}-#endif--module Text.RE.Internal.SearchReplace.PCRE.String-  ( ed-  , edMS-  , edMI-  , edBS-  , edBI-  , edMultilineSensitive-  , edMultilineInsensitive-  , edBlockSensitive-  , edBlockInsensitive-  , ed_-  ) where---import           Language.Haskell.TH-import           Language.Haskell.TH.Quote-import           Text.RE.PCRE.RE-import           Text.RE.Internal.SearchReplace.PCREEdPrime-import           Text.RE.SearchReplace-import           Text.RE.Types.REOptions----- | the @[ed| ... /// ... |]@ quasi quoters-ed-  , edMS-  , edMI-  , edBS-  , edBI-  , edMultilineSensitive-  , edMultilineInsensitive-  , edBlockSensitive-  , edBlockInsensitive-  , ed_ :: QuasiQuoter--ed                       = ed' sr_cast $ Just minBound-edMS                     = edMultilineSensitive-edMI                     = edMultilineInsensitive-edBS                     = edBlockSensitive-edBI                     = edBlockInsensitive-edMultilineSensitive     = ed' sr_cast $ Just  MultilineSensitive-edMultilineInsensitive   = ed' sr_cast $ Just  MultilineInsensitive-edBlockSensitive         = ed' sr_cast $ Just  BlockSensitive-edBlockInsensitive       = ed' sr_cast $ Just  BlockInsensitive-ed_                      = ed' fn_cast   Nothing--sr_cast :: Q Exp-sr_cast = [|\x -> x :: SearchReplace RE String|]--fn_cast :: Q Exp-fn_cast = [|\x -> x :: SimpleREOptions -> SearchReplace RE String|]
− Text/RE/Internal/SearchReplace/PCREEdPrime.hs
@@ -1,63 +0,0 @@-{-# LANGUAGE NoImplicitPrelude          #-}-{-# LANGUAGE FlexibleContexts           #-}-{-# LANGUAGE CPP                        #-}-#if __GLASGOW_HASKELL__ >= 800-{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}-{-# LANGUAGE TemplateHaskellQuotes      #-}-#else-{-# LANGUAGE QuasiQuotes                #-}-{-# LANGUAGE TemplateHaskell            #-}-#endif--module Text.RE.Internal.SearchReplace.PCREEdPrime-  ( ed'-  ) where--import           Language.Haskell.TH-import           Language.Haskell.TH.Quote-import           Prelude.Compat-import           Text.RE.Internal.SearchReplace-import           Text.RE.Internal.QQ-import           Text.RE.PCRE.RE-import           Text.RE.SearchReplace-import           Text.RE.Types.IsRegex-import           Text.RE.Types.REOptions-import           Text.RE.Types.Replace-import           Text.Regex.PCRE----- | construct a quasi quoter from a casting function and @Just sro@--- if the options are known, otherwise a function take takes the--- 'SimpleREOptions' and constructs the 'SearchReplace' template-ed' :: Q Exp -> Maybe SimpleREOptions -> QuasiQuoter-ed' qe mb = case mb of-  Nothing  ->-    (qq0 "ed'")-      { quoteExp = parse minBound $ \rs -> AppE <$> qe <*> [|flip unsafe_compile_sr rs|]-      }-  Just sro ->-    (qq0 "ed'")-      { quoteExp = parse sro $ \rs -> AppE <$> qe <*> [|unsafe_compile_sr_simple sro rs|]-      }-  where-    parse :: SimpleREOptions -> (String->Q Exp) -> String -> Q Exp-    parse sro mk ts = either error (\_->mk ts) ei-      where-        ei :: Either String (SearchReplace RE String)-        ei = compileSearchReplace_ id (compileRegexWith sro) ts--unsafe_compile_sr_simple :: IsRegex RE s-                         => SimpleREOptions-                         -> String-                         -> SearchReplace RE s-unsafe_compile_sr_simple sro =-    unsafe_compile_sr $ unpackSimpleREOptions sro--unsafe_compile_sr :: ( IsOption o RE CompOption ExecOption-                              , IsRegex RE s-                              )-                           => o-                           -> String-                           -> SearchReplace RE s-unsafe_compile_sr os =-    unsafeCompileSearchReplace_ packR $ compileRegexWithOptions os
Text/RE/PCRE.hs view
@@ -44,9 +44,9 @@   , escape   , escapeWith   , escapeREString-  , module Text.RE.PCRE.RE+  , module Text.RE.ZeInternals.PCRE   -- * The [ed| ... |] quasi quoters-  , module Text.RE.Internal.SearchReplace.PCRE+  , module Text.RE.ZeInternals.SearchReplace.PCRE   -- * The Operator Instances   -- $instances   , module Text.RE.PCRE.ByteString@@ -59,17 +59,16 @@  import qualified Text.Regex.Base                          as B import           Text.RE-import           Text.RE.Internal.AddCaptureNames-import           Text.RE.Internal.SearchReplace.PCRE-import           Text.RE.PCRE.RE+import           Text.RE.ZeInternals.AddCaptureNames+import           Text.RE.ZeInternals.SearchReplace.PCRE+import           Text.RE.ZeInternals.PCRE import qualified Text.Regex.PCRE                          as PCRE import           Text.RE.PCRE.ByteString() import           Text.RE.PCRE.ByteString.Lazy() import           Text.RE.PCRE.Sequence() import           Text.RE.PCRE.String()-import           Text.RE.SearchReplace-import           Text.RE.Types.IsRegex-import           Text.RE.Types.REOptions+import           Text.RE.IsRegex+import           Text.RE.REOptions   -- | find all matches in text; e.g., to count the number of naturals in s:@@ -128,7 +127,7 @@ -- -- * "Text.RE.PCRE.ByteString" -- * "Text.RE.PCRE.ByteString.Lazy"--- * "Text.RE.PCRE.RE"+-- * "Text.RE.ZeInternals.PCRE" -- * "Text.RE.PCRE.Sequence" -- * "Text.RE.PCRE.String" 
Text/RE/PCRE/ByteString.hs view
@@ -44,8 +44,8 @@   , escape   , escapeWith   , escapeREString-  , module Text.RE.PCRE.RE-  , module Text.RE.Internal.SearchReplace.PCRE.ByteString+  , module Text.RE.ZeInternals.PCRE+  , module Text.RE.ZeInternals.SearchReplace.PCRE.ByteString   ) where  import           Prelude.Compat@@ -53,13 +53,12 @@ import           Data.Typeable import           Text.Regex.Base import           Text.RE-import           Text.RE.Internal.AddCaptureNames-import           Text.RE.Internal.SearchReplace.PCRE.ByteString-import           Text.RE.SearchReplace-import           Text.RE.Types.IsRegex-import           Text.RE.Types.REOptions-import           Text.RE.Types.Replace-import           Text.RE.PCRE.RE+import           Text.RE.ZeInternals.AddCaptureNames+import           Text.RE.ZeInternals.SearchReplace.PCRE.ByteString+import           Text.RE.IsRegex+import           Text.RE.REOptions+import           Text.RE.Replace+import           Text.RE.ZeInternals.PCRE import qualified Text.Regex.PCRE               as PCRE  
Text/RE/PCRE/ByteString/Lazy.hs view
@@ -44,8 +44,8 @@   , escape   , escapeWith   , escapeREString-  , module Text.RE.PCRE.RE-  , module Text.RE.Internal.SearchReplace.PCRE.ByteString.Lazy+  , module Text.RE.ZeInternals.PCRE+  , module Text.RE.ZeInternals.SearchReplace.PCRE.ByteString.Lazy   ) where  import           Prelude.Compat@@ -53,13 +53,12 @@ import           Data.Typeable import           Text.Regex.Base import           Text.RE-import           Text.RE.Internal.AddCaptureNames-import           Text.RE.Internal.SearchReplace.PCRE.ByteString.Lazy-import           Text.RE.SearchReplace-import           Text.RE.Types.IsRegex-import           Text.RE.Types.REOptions-import           Text.RE.Types.Replace-import           Text.RE.PCRE.RE+import           Text.RE.ZeInternals.AddCaptureNames+import           Text.RE.ZeInternals.SearchReplace.PCRE.ByteString.Lazy+import           Text.RE.IsRegex+import           Text.RE.REOptions+import           Text.RE.Replace+import           Text.RE.ZeInternals.PCRE import qualified Text.Regex.PCRE               as PCRE  
− Text/RE/PCRE/RE.hs
@@ -1,412 +0,0 @@-{-# LANGUAGE NoImplicitPrelude          #-}-{-# LANGUAGE RecordWildCards            #-}-{-# LANGUAGE MultiParamTypeClasses      #-}-{-# LANGUAGE TypeSynonymInstances       #-}-{-# LANGUAGE FlexibleInstances          #-}-{-# LANGUAGE FlexibleContexts           #-}-{-# LANGUAGE CPP                        #-}-#if __GLASGOW_HASKELL__ >= 800-{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}-{-# LANGUAGE TemplateHaskellQuotes      #-}-#else-{-# LANGUAGE QuasiQuotes                #-}-{-# LANGUAGE TemplateHaskell            #-}-#endif-{-# OPTIONS_GHC -fno-warn-orphans       #-}--module Text.RE.PCRE.RE-  ( -- * About-    -- $about--    -- * RE Type-    RE-  , regexType-  , reOptions-  , reSource-  , reCaptureNames-  , reRegex-  -- * REOptions Type-  , REOptions-  , defaultREOptions-  , noPreludeREOptions-  -- * Compiling Regular Expressions-  , compileRegex-  , compileRegexWith-  , compileRegexWithOptions-  -- * Compiling Search-Replace Templates-  , compileSearchReplace-  , compileSearchReplaceWith-  , compileSearchReplaceWithREOptions-  -- * Escaping String-  , escape-  , escapeWith-  , escapeWithOptions-  , escapeREString-  -- * Macros Standard Environment-  , prelude-  , preludeEnv-  , preludeTestsFailing-  , preludeTable-  , preludeSummary-  , preludeSources-  , preludeSource-  , unpackSimpleREOptions-  -- * The Quasi Quoters-  , re-  , reMS-  , reMI-  , reBS-  , reBI-  , reMultilineSensitive-  , reMultilineInsensitive-  , reBlockSensitive-  , reBlockInsensitive-  , re_-  , cp-  ) where--import           Data.Bits-import           Data.Functor.Identity-import           Language.Haskell.TH-import           Language.Haskell.TH.Quote-import           Prelude.Compat-import           Text.RE.Internal.EscapeREString-import           Text.RE.Internal.NamedCaptures-import           Text.RE.Internal.PreludeMacros-import           Text.RE.Internal.QQ-import           Text.RE.Internal.SearchReplace-import           Text.RE.SearchReplace-import           Text.RE.TestBench-import           Text.RE.Types.CaptureID-import           Text.RE.Types.IsRegex-import           Text.RE.Types.REOptions-import           Text.RE.Types.Replace-import           Text.Regex.PCRE----- | the RE type for this back end representing a well-formed, compiled--- RE-data RE =-  RE-    { _re_options :: !REOptions-    , _re_source  :: !String-    , _re_cnames  :: !CaptureNames-    , _re_regex   :: !Regex-    }---- | some functions in the "Text.RE.TestBench" need the back end to--- be passed dynamically as a 'RegexType' parameters: use 'regexType'--- fpr this backend-regexType :: RegexType-regexType =-  mkPCRE $ \txt env md -> txt =~ mdRegexSource regexType ExclCaptures env md---- | extract the 'REOptions' from the @RE@-reOptions :: RE -> REOptions-reOptions = _re_options---- | extract the RE source string from the @RE@-reSource :: RE -> String-reSource = _re_source---- | extract the 'CaptureNames' from the @RE@-reCaptureNames :: RE -> CaptureNames-reCaptureNames = _re_cnames---- | extract the back end compiled 'Regex' type from the @RE@-reRegex  :: RE -> Regex-reRegex = _re_regex------------------------------------------------------------------------------ REOptions----------------------------------------------------------------------------- | and the REOptions for this back end (see "Text.RE.Types.REOptions"--- for details)-type REOptions = REOptions_ RE CompOption ExecOption--instance IsOption SimpleREOptions RE CompOption ExecOption where-  makeREOptions    = unpackSimpleREOptions--instance IsOption (Macros RE) RE CompOption ExecOption where-  makeREOptions ms = REOptions ms def_comp_option def_exec_option--instance IsOption CompOption  RE CompOption ExecOption where-  makeREOptions co = REOptions prelude co def_exec_option--instance IsOption ExecOption  RE CompOption ExecOption where-  makeREOptions eo = REOptions prelude def_comp_option eo--instance IsOption REOptions     RE CompOption ExecOption where-  makeREOptions    = id--instance IsOption ()          RE CompOption ExecOption where-  makeREOptions _  = unpackSimpleREOptions minBound---- | the default 'REOptions'-defaultREOptions :: REOptions-defaultREOptions = makeREOptions (minBound::SimpleREOptions)---- | the default 'REOptions' but with no RE macros defined-noPreludeREOptions :: REOptions-noPreludeREOptions = defaultREOptions { optionsMacs = emptyMacros }---- | convert a universal 'SimpleReOptions' into the 'REOptions' used--- by this back end-unpackSimpleREOptions :: SimpleREOptions -> REOptions-unpackSimpleREOptions sro =-  REOptions-    { optionsMacs = prelude-    , optionsComp = comp-    , optionsExec = defaultExecOpt-    }-  where-    comp =-      wiggle ml compMultiline $-      wiggle ci compCaseless-        defaultCompOpt--    wiggle True  m v = v .|.            m-    wiggle False m v = v .&. complement m--    (ml,ci) = case sro of-        MultilineSensitive    -> (,) True  False-        MultilineInsensitive  -> (,) True  True-        BlockSensitive        -> (,) False False-        BlockInsensitive      -> (,) False True------------------------------------------------------------------------------ Compiling Regular Expressions----------------------------------------------------------------------------- | compile a 'String' into a 'RE' with the default options,--- generating an error if the RE is not well formed-compileRegex :: (Functor m,Monad m) => String -> m RE-compileRegex = compileRegexWithOptions ()---- | compile a 'String' into a 'RE' using the given @SimpleREOptions@,--- generating an error if the RE is not well formed-compileRegexWith :: (Functor m,Monad m) => SimpleREOptions -> String -> m RE-compileRegexWith = compileRegexWithOptions---- | compile a 'String' into a 'RE' using the given @SimpleREOptions@,--- generating an error if the RE is not well formed-compileRegexWithOptions :: ( IsOption o RE CompOption ExecOption-                           , Functor m-                           , Monad   m-                           )-                        => o-                        -> String-                        -> m RE-compileRegexWithOptions = compileRegex_ . makeREOptions------------------------------------------------------------------------------ Compiling Search Replace Templates----------------------------------------------------------------------------- | compile a SearchReplace template generating errors if the RE or--- the template are not well formed -- all capture references being checked-compileSearchReplace :: (Monad m,Functor m,IsRegex RE s)-                     => String-                     -> String-                     -> m (SearchReplace RE s)-compileSearchReplace = compileSearchReplaceWith minBound---- | compile a SearchReplace template, with simple options, generating--- errors if the RE or the template are not well formed -- all capture--- references being checked-compileSearchReplaceWith :: (Monad m,Functor m,IsRegex RE s)-                         => SimpleREOptions-                         -> String-                         -> String-                         -> m (SearchReplace RE s)-compileSearchReplaceWith sro = compileSearchAndReplace_ packR $ compileRegexWith sro---- | compile a SearchReplace template, with general options, generating--- errors if the RE or the template are not well formed -- all capture--- references being checked-compileSearchReplaceWithREOptions :: (Monad m,Functor m,IsRegex RE s)-                                  => REOptions-                                  -> String-                                  -> String-                                  -> m (SearchReplace RE s)-compileSearchReplaceWithREOptions os = compileSearchAndReplace_ packR $ compileRegexWithOptions os------------------------------------------------------------------------------ Escaping Strings----------------------------------------------------------------------------- | convert a string into a RE that matches that string, and apply it--- to an argument continuation function to make up the RE string to be--- compiled-escape :: (Functor m,Monad m)-       => (String->String)-       -> String-       -> m RE-escape = escapeWith minBound---- | convert a string into a RE that matches that string, and apply it--- to an argument continuation function to make up the RE string to be--- compiled with the default options-escapeWith :: (Functor m,Monad m)-           => SimpleREOptions-           -> (String->String)-           -> String-           -> m RE-escapeWith = escapeWithOptions---- | convert a string into a RE that matches that string, and apply it--- to an argument continuation function to make up the RE string to be--- compiled the given options-escapeWithOptions :: ( IsOption o RE CompOption ExecOption-                     , Functor m-                     , Monad m-                     )-                  => o-                  -> (String->String)-                  -> String-                  -> m RE-escapeWithOptions o f = compileRegexWithOptions o . f . escapeREString------------------------------------------------------------------------------ Macro Standard Environment---------------------------------------------------------------------------prelude :: Macros RE-prelude = runIdentity $ preludeMacros mk regexType ExclCaptures-  where-    mk = Identity . unsafeCompileRegex_ noPreludeREOptions--preludeTestsFailing :: [MacroID]-preludeTestsFailing = badMacros preludeEnv--preludeEnv :: MacroEnv-preludeEnv = preludeMacroEnv regexType--preludeTable :: String-preludeTable = preludeMacroTable regexType--preludeSummary :: PreludeMacro -> String-preludeSummary = preludeMacroSummary regexType--preludeSources :: String-preludeSources = preludeMacroSources regexType--preludeSource :: PreludeMacro -> String-preludeSource = preludeMacroSource regexType------------------------------------------------------------------------------ Quasi Quoters----------------------------------------------------------------------------- | the @[re| ... |]@ and @[ed| ... /// ... |]@ quasi quoters-re-  , reMS-  , reMI-  , reBS-  , reBI-  , reMultilineSensitive-  , reMultilineInsensitive-  , reBlockSensitive-  , reBlockInsensitive-  , re_ :: QuasiQuoter--re                       = re' $ Just minBound-reMS                     = reMultilineSensitive-reMI                     = reMultilineInsensitive-reBS                     = reBlockSensitive-reBI                     = reBlockInsensitive-reMultilineSensitive     = re' $ Just  MultilineSensitive-reMultilineInsensitive   = re' $ Just  MultilineInsensitive-reBlockSensitive         = re' $ Just  BlockSensitive-reBlockInsensitive       = re' $ Just  BlockInsensitive-re_                      = re'   Nothing------------------------------------------------------------------------------ re Helpers---------------------------------------------------------------------------re' :: Maybe SimpleREOptions -> QuasiQuoter-re' mb = case mb of-  Nothing  ->-    (qq0 "re'")-      { quoteExp = parse minBound (\rs->[|flip unsafeCompileRegex rs|])-      }-  Just sro ->-    (qq0 "re'")-      { quoteExp = parse sro (\rs->[|unsafeCompileRegexSimple sro rs|])-      }-  where-    parse :: SimpleREOptions -> (String->Q Exp) -> String -> Q Exp-    parse sro mk rs = either error (\_->mk rs) $ compileRegex_ os rs-      where-        os = unpackSimpleREOptions sro--unsafeCompileRegexSimple :: SimpleREOptions -> String -> RE-unsafeCompileRegexSimple sro re_s = unsafeCompileRegex os re_s-  where-    os = unpackSimpleREOptions sro--unsafeCompileRegex :: IsOption o RE CompOption ExecOption-                   => o-                   -> String-                   -> RE-unsafeCompileRegex = unsafeCompileRegex_ . makeREOptions--unsafeCompileRegex_ :: REOptions -> String -> RE-unsafeCompileRegex_ os = either oops id . compileRegexWithOptions os-  where-    oops = error . ("unsafeCompileRegex: " ++)--compileRegex' :: (Functor m,Monad m)-              => REOptions-              -> String-              -> m (CaptureNames,Regex)-compileRegex' REOptions{..} s0 = do-    ((_,cnms),s2) <- either fail return $ extractNamedCaptures s1-    (,) cnms <$> makeRegexOptsM optionsComp optionsExec s2-  where-    s1 = expandMacros reSource optionsMacs s0--compileRegex_ :: ( Functor m , Monad m )-              => REOptions-              -> String-              -> m RE-compileRegex_ os re_s = uncurry mk <$> compileRegex' os re_s-  where-    mk cnms rex =-      RE-        { _re_options = os-        , _re_source  = re_s-        , _re_cnames  = cnms-        , _re_regex   = rex-        }------------------------------------------------------------------------------ Helpers---------------------------------------------------------------------------def_comp_option :: CompOption-def_comp_option = optionsComp defaultREOptions--def_exec_option :: ExecOption-def_exec_option = optionsExec defaultREOptions------------------------------------------------------------------------------ Haddock Sections----------------------------------------------------------------------------- $about------ This module provides the regex PCRE back end. Most of the functions that--- you will need for day to day use are provided by the primary API modules--- (e.g., "Text.RE.PCRE.ByteString").
Text/RE/PCRE/Sequence.hs view
@@ -44,8 +44,8 @@   , escape   , escapeWith   , escapeREString-  , module Text.RE.PCRE.RE-  , module Text.RE.Internal.SearchReplace.PCRE.Sequence+  , module Text.RE.ZeInternals.PCRE+  , module Text.RE.ZeInternals.SearchReplace.PCRE.Sequence   ) where  import           Prelude.Compat@@ -53,13 +53,12 @@ import           Data.Typeable import           Text.Regex.Base import           Text.RE-import           Text.RE.Internal.AddCaptureNames-import           Text.RE.Internal.SearchReplace.PCRE.Sequence-import           Text.RE.SearchReplace-import           Text.RE.Types.IsRegex-import           Text.RE.Types.REOptions-import           Text.RE.Types.Replace-import           Text.RE.PCRE.RE+import           Text.RE.ZeInternals.AddCaptureNames+import           Text.RE.ZeInternals.SearchReplace.PCRE.Sequence+import           Text.RE.IsRegex+import           Text.RE.REOptions+import           Text.RE.Replace+import           Text.RE.ZeInternals.PCRE import qualified Text.Regex.PCRE               as PCRE  
Text/RE/PCRE/String.hs view
@@ -44,8 +44,8 @@   , escape   , escapeWith   , escapeREString-  , module Text.RE.PCRE.RE-  , module Text.RE.Internal.SearchReplace.PCRE.String+  , module Text.RE.ZeInternals.PCRE+  , module Text.RE.ZeInternals.SearchReplace.PCRE.String   ) where  import           Prelude.Compat@@ -53,13 +53,12 @@ import           Data.Typeable import           Text.Regex.Base import           Text.RE-import           Text.RE.Internal.AddCaptureNames-import           Text.RE.Internal.SearchReplace.PCRE.String-import           Text.RE.SearchReplace-import           Text.RE.Types.IsRegex-import           Text.RE.Types.REOptions-import           Text.RE.Types.Replace-import           Text.RE.PCRE.RE+import           Text.RE.ZeInternals.AddCaptureNames+import           Text.RE.ZeInternals.SearchReplace.PCRE.String+import           Text.RE.IsRegex+import           Text.RE.REOptions+import           Text.RE.Replace+import           Text.RE.ZeInternals.PCRE import qualified Text.Regex.PCRE               as PCRE  
+ Text/RE/ZeInternals/PCRE.hs view
@@ -0,0 +1,411 @@+{-# LANGUAGE NoImplicitPrelude          #-}+{-# LANGUAGE RecordWildCards            #-}+{-# LANGUAGE MultiParamTypeClasses      #-}+{-# LANGUAGE TypeSynonymInstances       #-}+{-# LANGUAGE FlexibleInstances          #-}+{-# LANGUAGE FlexibleContexts           #-}+{-# LANGUAGE CPP                        #-}+#if __GLASGOW_HASKELL__ >= 800+{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}+{-# LANGUAGE TemplateHaskellQuotes      #-}+#else+{-# LANGUAGE QuasiQuotes                #-}+{-# LANGUAGE TemplateHaskell            #-}+#endif+{-# OPTIONS_GHC -fno-warn-orphans       #-}++module Text.RE.ZeInternals.PCRE+  ( -- * About+    -- $about++    -- * RE Type+    RE+  , regexType+  , reOptions+  , reSource+  , reCaptureNames+  , reRegex+  -- * REOptions Type+  , REOptions+  , defaultREOptions+  , noPreludeREOptions+  -- * Compiling Regular Expressions+  , compileRegex+  , compileRegexWith+  , compileRegexWithOptions+  -- * Compiling Search-Replace Templates+  , compileSearchReplace+  , compileSearchReplaceWith+  , compileSearchReplaceWithREOptions+  -- * Escaping String+  , escape+  , escapeWith+  , escapeWithOptions+  , escapeREString+  -- * Macros Standard Environment+  , prelude+  , preludeEnv+  , preludeTestsFailing+  , preludeTable+  , preludeSummary+  , preludeSources+  , preludeSource+  , unpackSimpleREOptions+  -- * The Quasi Quoters+  , re+  , reMS+  , reMI+  , reBS+  , reBI+  , reMultilineSensitive+  , reMultilineInsensitive+  , reBlockSensitive+  , reBlockInsensitive+  , re_+  , cp+  ) where++import           Data.Bits+import           Data.Functor.Identity+import           Language.Haskell.TH+import           Language.Haskell.TH.Quote+import           Prelude.Compat+import           Text.RE.IsRegex+import           Text.RE.REOptions+import           Text.RE.ZeInternals.EscapeREString+import           Text.RE.ZeInternals.NamedCaptures+import           Text.RE.ZeInternals.PreludeMacros+import           Text.RE.ZeInternals.Replace+import           Text.RE.ZeInternals.QQ+import           Text.RE.ZeInternals.SearchReplace+import           Text.RE.ZeInternals.TestBench+import           Text.RE.ZeInternals.Types.CaptureID+import           Text.Regex.PCRE+++-- | the RE type for this back end representing a well-formed, compiled+-- RE+data RE =+  RE+    { _re_options :: !REOptions+    , _re_source  :: !String+    , _re_cnames  :: !CaptureNames+    , _re_regex   :: !Regex+    }++-- | some functions in the "Text.RE.TestBench" need the back end to+-- be passed dynamically as a 'RegexType' parameters: use 'regexType'+-- fpr this backend+regexType :: RegexType+regexType =+  mkPCRE $ \txt env md -> txt =~ mdRegexSource regexType ExclCaptures env md++-- | extract the 'REOptions' from the @RE@+reOptions :: RE -> REOptions+reOptions = _re_options++-- | extract the RE source string from the @RE@+reSource :: RE -> String+reSource = _re_source++-- | extract the 'CaptureNames' from the @RE@+reCaptureNames :: RE -> CaptureNames+reCaptureNames = _re_cnames++-- | extract the back end compiled 'Regex' type from the @RE@+reRegex  :: RE -> Regex+reRegex = _re_regex+++------------------------------------------------------------------------+-- REOptions+------------------------------------------------------------------------++-- | and the REOptions for this back end (see "Text.RE.REOptions"+-- for details)+type REOptions = REOptions_ RE CompOption ExecOption++instance IsOption SimpleREOptions RE CompOption ExecOption where+  makeREOptions    = unpackSimpleREOptions++instance IsOption (Macros RE) RE CompOption ExecOption where+  makeREOptions ms = REOptions ms def_comp_option def_exec_option++instance IsOption CompOption  RE CompOption ExecOption where+  makeREOptions co = REOptions prelude co def_exec_option++instance IsOption ExecOption  RE CompOption ExecOption where+  makeREOptions eo = REOptions prelude def_comp_option eo++instance IsOption REOptions     RE CompOption ExecOption where+  makeREOptions    = id++instance IsOption ()          RE CompOption ExecOption where+  makeREOptions _  = unpackSimpleREOptions minBound++-- | the default 'REOptions'+defaultREOptions :: REOptions+defaultREOptions = makeREOptions (minBound::SimpleREOptions)++-- | the default 'REOptions' but with no RE macros defined+noPreludeREOptions :: REOptions+noPreludeREOptions = defaultREOptions { optionsMacs = emptyMacros }++-- | convert a universal 'SimpleReOptions' into the 'REOptions' used+-- by this back end+unpackSimpleREOptions :: SimpleREOptions -> REOptions+unpackSimpleREOptions sro =+  REOptions+    { optionsMacs = prelude+    , optionsComp = comp+    , optionsExec = defaultExecOpt+    }+  where+    comp =+      wiggle ml compMultiline $+      wiggle ci compCaseless+        defaultCompOpt++    wiggle True  m v = v .|.            m+    wiggle False m v = v .&. complement m++    (ml,ci) = case sro of+        MultilineSensitive    -> (,) True  False+        MultilineInsensitive  -> (,) True  True+        BlockSensitive        -> (,) False False+        BlockInsensitive      -> (,) False True+++------------------------------------------------------------------------+-- Compiling Regular Expressions+------------------------------------------------------------------------++-- | compile a 'String' into a 'RE' with the default options,+-- generating an error if the RE is not well formed+compileRegex :: (Functor m,Monad m) => String -> m RE+compileRegex = compileRegexWithOptions ()++-- | compile a 'String' into a 'RE' using the given @SimpleREOptions@,+-- generating an error if the RE is not well formed+compileRegexWith :: (Functor m,Monad m) => SimpleREOptions -> String -> m RE+compileRegexWith = compileRegexWithOptions++-- | compile a 'String' into a 'RE' using the given @SimpleREOptions@,+-- generating an error if the RE is not well formed+compileRegexWithOptions :: ( IsOption o RE CompOption ExecOption+                           , Functor m+                           , Monad   m+                           )+                        => o+                        -> String+                        -> m RE+compileRegexWithOptions = compileRegex_ . makeREOptions+++------------------------------------------------------------------------+-- Compiling Search Replace Templates+------------------------------------------------------------------------++-- | compile a SearchReplace template generating errors if the RE or+-- the template are not well formed -- all capture references being checked+compileSearchReplace :: (Monad m,Functor m,IsRegex RE s)+                     => String+                     -> String+                     -> m (SearchReplace RE s)+compileSearchReplace = compileSearchReplaceWith minBound++-- | compile a SearchReplace template, with simple options, generating+-- errors if the RE or the template are not well formed -- all capture+-- references being checked+compileSearchReplaceWith :: (Monad m,Functor m,IsRegex RE s)+                         => SimpleREOptions+                         -> String+                         -> String+                         -> m (SearchReplace RE s)+compileSearchReplaceWith sro = compileSearchAndReplace_ packR $ compileRegexWith sro++-- | compile a SearchReplace template, with general options, generating+-- errors if the RE or the template are not well formed -- all capture+-- references being checked+compileSearchReplaceWithREOptions :: (Monad m,Functor m,IsRegex RE s)+                                  => REOptions+                                  -> String+                                  -> String+                                  -> m (SearchReplace RE s)+compileSearchReplaceWithREOptions os = compileSearchAndReplace_ packR $ compileRegexWithOptions os+++------------------------------------------------------------------------+-- Escaping Strings+------------------------------------------------------------------------++-- | convert a string into a RE that matches that string, and apply it+-- to an argument continuation function to make up the RE string to be+-- compiled+escape :: (Functor m,Monad m)+       => (String->String)+       -> String+       -> m RE+escape = escapeWith minBound++-- | convert a string into a RE that matches that string, and apply it+-- to an argument continuation function to make up the RE string to be+-- compiled with the default options+escapeWith :: (Functor m,Monad m)+           => SimpleREOptions+           -> (String->String)+           -> String+           -> m RE+escapeWith = escapeWithOptions++-- | convert a string into a RE that matches that string, and apply it+-- to an argument continuation function to make up the RE string to be+-- compiled the given options+escapeWithOptions :: ( IsOption o RE CompOption ExecOption+                     , Functor m+                     , Monad m+                     )+                  => o+                  -> (String->String)+                  -> String+                  -> m RE+escapeWithOptions o f = compileRegexWithOptions o . f . escapeREString+++------------------------------------------------------------------------+-- Macro Standard Environment+------------------------------------------------------------------------++prelude :: Macros RE+prelude = runIdentity $ preludeMacros mk regexType ExclCaptures+  where+    mk = Identity . unsafeCompileRegex_ noPreludeREOptions++preludeTestsFailing :: [MacroID]+preludeTestsFailing = badMacros preludeEnv++preludeEnv :: MacroEnv+preludeEnv = preludeMacroEnv regexType++preludeTable :: String+preludeTable = preludeMacroTable regexType++preludeSummary :: PreludeMacro -> String+preludeSummary = preludeMacroSummary regexType++preludeSources :: String+preludeSources = preludeMacroSources regexType++preludeSource :: PreludeMacro -> String+preludeSource = preludeMacroSource regexType+++------------------------------------------------------------------------+-- Quasi Quoters+------------------------------------------------------------------------++-- | the @[re| ... |]@ and @[ed| ... /// ... |]@ quasi quoters+re+  , reMS+  , reMI+  , reBS+  , reBI+  , reMultilineSensitive+  , reMultilineInsensitive+  , reBlockSensitive+  , reBlockInsensitive+  , re_ :: QuasiQuoter++re                       = re' $ Just minBound+reMS                     = reMultilineSensitive+reMI                     = reMultilineInsensitive+reBS                     = reBlockSensitive+reBI                     = reBlockInsensitive+reMultilineSensitive     = re' $ Just  MultilineSensitive+reMultilineInsensitive   = re' $ Just  MultilineInsensitive+reBlockSensitive         = re' $ Just  BlockSensitive+reBlockInsensitive       = re' $ Just  BlockInsensitive+re_                      = re'   Nothing+++------------------------------------------------------------------------+-- re Helpers+------------------------------------------------------------------------++re' :: Maybe SimpleREOptions -> QuasiQuoter+re' mb = case mb of+  Nothing  ->+    (qq0 "re'")+      { quoteExp = parse minBound (\rs->[|flip unsafeCompileRegex rs|])+      }+  Just sro ->+    (qq0 "re'")+      { quoteExp = parse sro (\rs->[|unsafeCompileRegexSimple sro rs|])+      }+  where+    parse :: SimpleREOptions -> (String->Q Exp) -> String -> Q Exp+    parse sro mk rs = either error (\_->mk rs) $ compileRegex_ os rs+      where+        os = unpackSimpleREOptions sro++unsafeCompileRegexSimple :: SimpleREOptions -> String -> RE+unsafeCompileRegexSimple sro re_s = unsafeCompileRegex os re_s+  where+    os = unpackSimpleREOptions sro++unsafeCompileRegex :: IsOption o RE CompOption ExecOption+                   => o+                   -> String+                   -> RE+unsafeCompileRegex = unsafeCompileRegex_ . makeREOptions++unsafeCompileRegex_ :: REOptions -> String -> RE+unsafeCompileRegex_ os = either oops id . compileRegexWithOptions os+  where+    oops = error . ("unsafeCompileRegex: " ++)++compileRegex' :: (Functor m,Monad m)+              => REOptions+              -> String+              -> m (CaptureNames,Regex)+compileRegex' REOptions{..} s0 = do+    ((_,cnms),s2) <- either fail return $ extractNamedCaptures s1+    (,) cnms <$> makeRegexOptsM optionsComp optionsExec s2+  where+    s1 = expandMacros reSource optionsMacs s0++compileRegex_ :: ( Functor m , Monad m )+              => REOptions+              -> String+              -> m RE+compileRegex_ os re_s = uncurry mk <$> compileRegex' os re_s+  where+    mk cnms rex =+      RE+        { _re_options = os+        , _re_source  = re_s+        , _re_cnames  = cnms+        , _re_regex   = rex+        }+++------------------------------------------------------------------------+-- Helpers+------------------------------------------------------------------------++def_comp_option :: CompOption+def_comp_option = optionsComp defaultREOptions++def_exec_option :: ExecOption+def_exec_option = optionsExec defaultREOptions+++------------------------------------------------------------------------+-- Haddock Sections+------------------------------------------------------------------------++-- $about+--+-- This module provides the regex PCRE back end. Most of the functions that+-- you will need for day to day use are provided by the primary API modules+-- (e.g., "Text.RE.PCRE.ByteString").
+ Text/RE/ZeInternals/QQ.hs view
@@ -0,0 +1,29 @@+{-# LANGUAGE DeriveDataTypeable         #-}++module Text.RE.ZeInternals.QQ where++import           Control.Exception+import           Data.Typeable+import           Language.Haskell.TH.Quote+++-- | used to throw an exception reporting an abuse of a quasi quoter+data QQFailure =+  QQFailure+    { _qqf_context   :: String  -- ^ in what context was the quasi quoter used+    , _qqf_component :: String  -- ^ how was the quasi quoter being abused+    }+  deriving (Show,Typeable)++instance Exception QQFailure where++-- | a quasi quoter that can be used in no context (to be extended with+-- the appropriate quasi quoter parser)+qq0 :: String -> QuasiQuoter+qq0 ctx =+  QuasiQuoter+    { quoteExp  = const $ throw $ QQFailure ctx "expression"+    , quotePat  = const $ throw $ QQFailure ctx "pattern"+    , quoteType = const $ throw $ QQFailure ctx "type"+    , quoteDec  = const $ throw $ QQFailure ctx "declaration"+    }
+ Text/RE/ZeInternals/SearchReplace.hs view
@@ -0,0 +1,84 @@+{-# LANGUAGE NoImplicitPrelude          #-}+{-# LANGUAGE RecordWildCards            #-}+{-# LANGUAGE CPP                        #-}+#if __GLASGOW_HASKELL__ >= 800+{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}+{-# LANGUAGE TemplateHaskellQuotes      #-}+#else+{-# LANGUAGE QuasiQuotes                #-}+{-# LANGUAGE TemplateHaskell            #-}+#endif+{-# OPTIONS_GHC -fno-warn-orphans       #-}++module Text.RE.ZeInternals.SearchReplace+  ( unsafeCompileSearchReplace_+  , compileSearchReplace_+  , compileSearchAndReplace_+  ) where++import qualified Data.HashMap.Strict            as HMS+import           Prelude.Compat+import           Text.RE.ZeInternals.NamedCaptures+import           Text.RE.ZeInternals.Replace+import           Text.RE.ZeInternals.Types.Capture+import           Text.RE.ZeInternals.Types.CaptureID+import           Text.RE.ZeInternals.Types.Matches+import           Text.RE.ZeInternals.Types.SearchReplace+import qualified Text.Regex.TDFA                as TDFA+++-- | warapper on 'compileSearchReplace_' that will generate an error+-- if any compilation errors are found+unsafeCompileSearchReplace_ :: (String->s)+                            -> (String->Either String re)+                            -> String+                            -> SearchReplace re s+unsafeCompileSearchReplace_ pk cf = either err id . compileSearchReplace_ pk cf+  where+    err msg = error $ "unsafeCompileSearchReplace_: " ++ msg++-- | compile a SearchReplace template generating errors if the RE or+-- the template are not well formed -- all capture references being checked+compileSearchReplace_ :: (Monad m,Functor m)+                      => (String->s)+                      -> (String->Either String re)+                      -> String+                      -> m (SearchReplace re s)+compileSearchReplace_ pack compile_re sr_tpl = either fail return $ do+    case mainCaptures $ sr_tpl $=~ "///" of+      [cap] ->+        compileSearchAndReplace_ pack compile_re+                      (capturePrefix cap) (captureSuffix cap)+      _ -> Left $ "bad search-replace template syntax: " ++ sr_tpl++-- | compile 'SearcgReplace' from two strings containing the RE+-- and the replacement template+compileSearchAndReplace_ :: (Monad m,Functor m)+                         => (String->s)+                         -> (String->Either String re)+                         -> String+                         -> String+                         -> m (SearchReplace re s)+compileSearchAndReplace_ pack compile_re re_s tpl = either fail return $ do+    re           <- compile_re re_s+    ((n,cnms),_) <- extractNamedCaptures re_s+    mapM_ (check n cnms) $ templateCaptures id tpl+    return $ SearchReplace re $ pack tpl+  where+    check :: Int -> CaptureNames -> CaptureID -> Either String ()+    check n cnms cid = case cid of+      IsCaptureOrdinal co -> check_co n    co+      IsCaptureName    cn -> check_cn cnms cn++    check_co n (CaptureOrdinal i) = case i <= n of+      True  -> return ()+      False -> Left $ "capture ordinal out of range: " +++                                      show i ++ " >= " ++ show n++    check_cn cnms cnm = case cnm `HMS.member` cnms of+      True  -> return ()+      False -> Left $ "capture name not defined: " +++                                      show (getCaptureName cnm)++($=~) :: String -> String -> Matches String+($=~) = (TDFA.=~)
+ Text/RE/ZeInternals/SearchReplace/PCRE.hs view
@@ -0,0 +1,54 @@+{-# LANGUAGE NoImplicitPrelude          #-}+{-# LANGUAGE CPP                        #-}+#if __GLASGOW_HASKELL__ >= 800+{-# LANGUAGE TemplateHaskellQuotes      #-}+#else+{-# LANGUAGE QuasiQuotes                #-}+{-# LANGUAGE TemplateHaskell            #-}+#endif++module Text.RE.ZeInternals.SearchReplace.PCRE+  ( ed+  , edMS+  , edMI+  , edBS+  , edBI+  , edMultilineSensitive+  , edMultilineInsensitive+  , edBlockSensitive+  , edBlockInsensitive+  , ed_+  ) where++import           Language.Haskell.TH+import           Language.Haskell.TH.Quote+import           Prelude.Compat+import           Text.RE.ZeInternals.SearchReplace.PCREEdPrime+import           Text.RE.REOptions+++-- | the @[ed| ... /// ... |]@ quasi quoters+ed+  , edMS+  , edMI+  , edBS+  , edBI+  , edMultilineSensitive+  , edMultilineInsensitive+  , edBlockSensitive+  , edBlockInsensitive+  , ed_ :: QuasiQuoter++ed                       = ed' cast $ Just minBound+edMS                     = edMultilineSensitive+edMI                     = edMultilineInsensitive+edBS                     = edBlockSensitive+edBI                     = edBlockInsensitive+edMultilineSensitive     = ed' cast $ Just  MultilineSensitive+edMultilineInsensitive   = ed' cast $ Just  MultilineInsensitive+edBlockSensitive         = ed' cast $ Just  BlockSensitive+edBlockInsensitive       = ed' cast $ Just  BlockInsensitive+ed_                      = ed' cast   Nothing++cast :: Q Exp+cast = [|id|]
+ Text/RE/ZeInternals/SearchReplace/PCRE/ByteString.hs view
@@ -0,0 +1,58 @@+{-# LANGUAGE CPP                        #-}+#if __GLASGOW_HASKELL__ >= 800+{-# LANGUAGE TemplateHaskellQuotes      #-}+#else+{-# LANGUAGE QuasiQuotes                #-}+{-# LANGUAGE TemplateHaskell            #-}+#endif++module Text.RE.ZeInternals.SearchReplace.PCRE.ByteString+  ( ed+  , edMS+  , edMI+  , edBS+  , edBI+  , edMultilineSensitive+  , edMultilineInsensitive+  , edBlockSensitive+  , edBlockInsensitive+  , ed_+  ) where++import qualified Data.ByteString.Char8         as B+import           Language.Haskell.TH+import           Language.Haskell.TH.Quote+import           Text.RE.ZeInternals.PCRE+import           Text.RE.ZeInternals.SearchReplace.PCREEdPrime+import           Text.RE.REOptions+import           Text.RE.ZeInternals.Types.SearchReplace+++-- | the @[ed| ... /// ... |]@ quasi quoters+ed+  , edMS+  , edMI+  , edBS+  , edBI+  , edMultilineSensitive+  , edMultilineInsensitive+  , edBlockSensitive+  , edBlockInsensitive+  , ed_ :: QuasiQuoter++ed                       = ed' sr_cast $ Just minBound+edMS                     = edMultilineSensitive+edMI                     = edMultilineInsensitive+edBS                     = edBlockSensitive+edBI                     = edBlockInsensitive+edMultilineSensitive     = ed' sr_cast $ Just  MultilineSensitive+edMultilineInsensitive   = ed' sr_cast $ Just  MultilineInsensitive+edBlockSensitive         = ed' sr_cast $ Just  BlockSensitive+edBlockInsensitive       = ed' sr_cast $ Just  BlockInsensitive+ed_                      = ed' fn_cast   Nothing++sr_cast :: Q Exp+sr_cast = [|\x -> x :: SearchReplace RE B.ByteString|]++fn_cast :: Q Exp+fn_cast = [|\x -> x :: SimpleREOptions -> SearchReplace RE B.ByteString|]
+ Text/RE/ZeInternals/SearchReplace/PCRE/ByteString/Lazy.hs view
@@ -0,0 +1,58 @@+{-# LANGUAGE CPP                        #-}+#if __GLASGOW_HASKELL__ >= 800+{-# LANGUAGE TemplateHaskellQuotes      #-}+#else+{-# LANGUAGE QuasiQuotes                #-}+{-# LANGUAGE TemplateHaskell            #-}+#endif++module Text.RE.ZeInternals.SearchReplace.PCRE.ByteString.Lazy+  ( ed+  , edMS+  , edMI+  , edBS+  , edBI+  , edMultilineSensitive+  , edMultilineInsensitive+  , edBlockSensitive+  , edBlockInsensitive+  , ed_+  ) where++import qualified Data.ByteString.Lazy.Char8    as LBS+import           Language.Haskell.TH+import           Language.Haskell.TH.Quote+import           Text.RE.ZeInternals.PCRE+import           Text.RE.ZeInternals.SearchReplace.PCREEdPrime+import           Text.RE.REOptions+import           Text.RE.ZeInternals.Types.SearchReplace+++-- | the @[ed| ... /// ... |]@ quasi quoters+ed+  , edMS+  , edMI+  , edBS+  , edBI+  , edMultilineSensitive+  , edMultilineInsensitive+  , edBlockSensitive+  , edBlockInsensitive+  , ed_ :: QuasiQuoter++ed                       = ed' sr_cast $ Just minBound+edMS                     = edMultilineSensitive+edMI                     = edMultilineInsensitive+edBS                     = edBlockSensitive+edBI                     = edBlockInsensitive+edMultilineSensitive     = ed' sr_cast $ Just  MultilineSensitive+edMultilineInsensitive   = ed' sr_cast $ Just  MultilineInsensitive+edBlockSensitive         = ed' sr_cast $ Just  BlockSensitive+edBlockInsensitive       = ed' sr_cast $ Just  BlockInsensitive+ed_                      = ed' fn_cast   Nothing++sr_cast :: Q Exp+sr_cast = [|\x -> x :: SearchReplace RE LBS.ByteString|]++fn_cast :: Q Exp+fn_cast = [|\x -> x :: SimpleREOptions -> SearchReplace RE LBS.ByteString|]
+ Text/RE/ZeInternals/SearchReplace/PCRE/Sequence.hs view
@@ -0,0 +1,58 @@+{-# LANGUAGE CPP                        #-}+#if __GLASGOW_HASKELL__ >= 800+{-# LANGUAGE TemplateHaskellQuotes      #-}+#else+{-# LANGUAGE QuasiQuotes                #-}+{-# LANGUAGE TemplateHaskell            #-}+#endif++module Text.RE.ZeInternals.SearchReplace.PCRE.Sequence+  ( ed+  , edMS+  , edMI+  , edBS+  , edBI+  , edMultilineSensitive+  , edMultilineInsensitive+  , edBlockSensitive+  , edBlockInsensitive+  , ed_+  ) where++import qualified Data.Sequence                 as S+import           Language.Haskell.TH+import           Language.Haskell.TH.Quote+import           Text.RE.ZeInternals.PCRE+import           Text.RE.ZeInternals.SearchReplace.PCREEdPrime+import           Text.RE.REOptions+import           Text.RE.ZeInternals.Types.SearchReplace+++-- | the @[ed| ... /// ... |]@ quasi quoters+ed+  , edMS+  , edMI+  , edBS+  , edBI+  , edMultilineSensitive+  , edMultilineInsensitive+  , edBlockSensitive+  , edBlockInsensitive+  , ed_ :: QuasiQuoter++ed                       = ed' sr_cast $ Just minBound+edMS                     = edMultilineSensitive+edMI                     = edMultilineInsensitive+edBS                     = edBlockSensitive+edBI                     = edBlockInsensitive+edMultilineSensitive     = ed' sr_cast $ Just  MultilineSensitive+edMultilineInsensitive   = ed' sr_cast $ Just  MultilineInsensitive+edBlockSensitive         = ed' sr_cast $ Just  BlockSensitive+edBlockInsensitive       = ed' sr_cast $ Just  BlockInsensitive+ed_                      = ed' fn_cast   Nothing++sr_cast :: Q Exp+sr_cast = [|\x -> x :: SearchReplace RE (S.Seq Char)|]++fn_cast :: Q Exp+fn_cast = [|\x -> x :: SimpleREOptions -> SearchReplace RE (S.Seq Char)|]
+ Text/RE/ZeInternals/SearchReplace/PCRE/String.hs view
@@ -0,0 +1,58 @@+{-# LANGUAGE CPP                        #-}+#if __GLASGOW_HASKELL__ >= 800+{-# LANGUAGE TemplateHaskellQuotes      #-}+#else+{-# LANGUAGE QuasiQuotes                #-}+{-# LANGUAGE TemplateHaskell            #-}+#endif++module Text.RE.ZeInternals.SearchReplace.PCRE.String+  ( ed+  , edMS+  , edMI+  , edBS+  , edBI+  , edMultilineSensitive+  , edMultilineInsensitive+  , edBlockSensitive+  , edBlockInsensitive+  , ed_+  ) where+++import           Language.Haskell.TH+import           Language.Haskell.TH.Quote+import           Text.RE.ZeInternals.PCRE+import           Text.RE.ZeInternals.SearchReplace.PCREEdPrime+import           Text.RE.REOptions+import           Text.RE.ZeInternals.Types.SearchReplace+++-- | the @[ed| ... /// ... |]@ quasi quoters+ed+  , edMS+  , edMI+  , edBS+  , edBI+  , edMultilineSensitive+  , edMultilineInsensitive+  , edBlockSensitive+  , edBlockInsensitive+  , ed_ :: QuasiQuoter++ed                       = ed' sr_cast $ Just minBound+edMS                     = edMultilineSensitive+edMI                     = edMultilineInsensitive+edBS                     = edBlockSensitive+edBI                     = edBlockInsensitive+edMultilineSensitive     = ed' sr_cast $ Just  MultilineSensitive+edMultilineInsensitive   = ed' sr_cast $ Just  MultilineInsensitive+edBlockSensitive         = ed' sr_cast $ Just  BlockSensitive+edBlockInsensitive       = ed' sr_cast $ Just  BlockInsensitive+ed_                      = ed' fn_cast   Nothing++sr_cast :: Q Exp+sr_cast = [|\x -> x :: SearchReplace RE String|]++fn_cast :: Q Exp+fn_cast = [|\x -> x :: SimpleREOptions -> SearchReplace RE String|]
+ Text/RE/ZeInternals/SearchReplace/PCREEdPrime.hs view
@@ -0,0 +1,62 @@+{-# LANGUAGE NoImplicitPrelude          #-}+{-# LANGUAGE FlexibleContexts           #-}+{-# LANGUAGE CPP                        #-}+#if __GLASGOW_HASKELL__ >= 800+{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}+{-# LANGUAGE TemplateHaskellQuotes      #-}+#else+{-# LANGUAGE QuasiQuotes                #-}+{-# LANGUAGE TemplateHaskell            #-}+#endif++module Text.RE.ZeInternals.SearchReplace.PCREEdPrime+  ( ed'+  ) where++import           Language.Haskell.TH+import           Language.Haskell.TH.Quote+import           Prelude.Compat+import           Text.RE.ZeInternals.SearchReplace+import           Text.RE.ZeInternals.QQ+import           Text.RE.ZeInternals.PCRE+import           Text.RE.IsRegex+import           Text.RE.REOptions+import           Text.RE.Replace+import           Text.Regex.PCRE+++-- | construct a quasi quoter from a casting function and @Just sro@+-- if the options are known, otherwise a function take takes the+-- 'SimpleREOptions' and constructs the 'SearchReplace' template+ed' :: Q Exp -> Maybe SimpleREOptions -> QuasiQuoter+ed' qe mb = case mb of+  Nothing  ->+    (qq0 "ed'")+      { quoteExp = parse minBound $ \rs -> AppE <$> qe <*> [|flip unsafe_compile_sr rs|]+      }+  Just sro ->+    (qq0 "ed'")+      { quoteExp = parse sro $ \rs -> AppE <$> qe <*> [|unsafe_compile_sr_simple sro rs|]+      }+  where+    parse :: SimpleREOptions -> (String->Q Exp) -> String -> Q Exp+    parse sro mk ts = either error (\_->mk ts) ei+      where+        ei :: Either String (SearchReplace RE String)+        ei = compileSearchReplace_ id (compileRegexWith sro) ts++unsafe_compile_sr_simple :: IsRegex RE s+                         => SimpleREOptions+                         -> String+                         -> SearchReplace RE s+unsafe_compile_sr_simple sro =+    unsafe_compile_sr $ unpackSimpleREOptions sro++unsafe_compile_sr :: ( IsOption o RE CompOption ExecOption+                              , IsRegex RE s+                              )+                           => o+                           -> String+                           -> SearchReplace RE s+unsafe_compile_sr os =+    unsafeCompileSearchReplace_ packR $ compileRegexWithOptions os
changelog view
@@ -1,5 +1,10 @@ -*-change-log-*- +0.11.0.0 Chris Dornan <chris.dornan@irisconnect.co.uk> 2017-03-29+  * Simplify API (#97)+  * Rename Location to RELocation (#98)+  * Rename the MacrosDescriptor Fields #99+ 0.10.0.3 Chris Dornan <chris.dornan@irisconnect.co.uk> 2017-03-28   * Update to LTS-8.6 (#95)   * Improve Haddocks for Text.RE.{TDFA,PCRE} (#94)
regex-with-pcre.cabal view
@@ -1,5 +1,5 @@ Name:                   regex-with-pcre-Version:                0.10.0.3+Version:                0.11.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.10.0.3+    Tag:                0.11.0.0   @@ -42,19 +42,19 @@       Text.RE.PCRE       Text.RE.PCRE.ByteString       Text.RE.PCRE.ByteString.Lazy-      Text.RE.PCRE.RE+      Text.RE.ZeInternals.PCRE       Text.RE.PCRE.Sequence       Text.RE.PCRE.String      Other-Modules:-      Text.RE.Internal.QQ-      Text.RE.Internal.SearchReplace-      Text.RE.Internal.SearchReplace.PCRE-      Text.RE.Internal.SearchReplace.PCRE.ByteString-      Text.RE.Internal.SearchReplace.PCRE.ByteString.Lazy-      Text.RE.Internal.SearchReplace.PCRE.Sequence-      Text.RE.Internal.SearchReplace.PCRE.String-      Text.RE.Internal.SearchReplace.PCREEdPrime+      Text.RE.ZeInternals.QQ+      Text.RE.ZeInternals.SearchReplace+      Text.RE.ZeInternals.SearchReplace.PCRE+      Text.RE.ZeInternals.SearchReplace.PCRE.ByteString+      Text.RE.ZeInternals.SearchReplace.PCRE.ByteString.Lazy+      Text.RE.ZeInternals.SearchReplace.PCRE.Sequence+      Text.RE.ZeInternals.SearchReplace.PCRE.String+      Text.RE.ZeInternals.SearchReplace.PCREEdPrime      Default-Language:   Haskell2010 @@ -89,7 +89,7 @@       -Wwarn      Build-depends:-        regex                == 0.10.0.3+        regex                == 0.11.0.0       , base                 >= 4 && < 5       , base-compat          >= 0.6.0       , bytestring           >= 0.10.2.0