packages feed

regex-tdfa 1.3.2.4 → 1.3.2.5

raw patch · 10 files changed

+52/−29 lines, 10 filesdep ~basedep ~containersdep ~mtl

Dependency ranges changed: base, containers, mtl, text

Files

CHANGELOG.md view
@@ -1,3 +1,12 @@+### 1.3.2.5++_2025-09-29 Andreas Abel_++- Bump `cabal-version` to 2.0 to support field `autogen-modules` ([#70](https://github.com/haskell-hvr/regex-tdfa/pull/70))+- SPECIALIZE pragmas for faster `Text` matching ([#72](https://github.com/haskell-hvr/regex-tdfa/pull/72))+- Address deprecation warning for `sizeofMutualByteArray#` ([#71](https://github.com/haskell-hvr/regex-tdfa/issues/71))+- Tested with GHC 8.0 - 9.12.2+ ### 1.3.2.4  _2025-05-09 Andreas Abel_
lib/Text/Regex/TDFA/NewDFA/Engine.hs view
@@ -16,7 +16,7 @@ -- #ifdef __GLASGOW_HASKELL__ import GHC.Arr(STArray(..)) import GHC.ST(ST(..))-import GHC.Exts(MutableByteArray#,RealWorld,Int#,sizeofMutableByteArray#,State#)+import GHC.Exts(MutableByteArray#,RealWorld,Int#,getSizeofMutableByteArray#,State#) import Unsafe.Coerce (unsafeCoerce) {- -- #else@@ -36,7 +36,8 @@ import Data.Monoid as Mon(Monoid(..)) import qualified Data.IntSet as ISet(toAscList) import Data.Array.IArray((!))-import Data.List(partition,sort,foldl',sortBy,groupBy)+import Data.List(partition,sort,sortBy,groupBy)+import qualified Data.List as List import Data.STRef(STRef,newSTRef,readSTRef,writeSTRef) import qualified Control.Monad.ST.Lazy as L(ST,runST,strictToLazyST) import qualified Control.Monad.ST.Strict as S(ST)@@ -44,6 +45,8 @@ import qualified Data.Sequence as Seq(null) import qualified Data.ByteString.Char8 as SBS(ByteString) import qualified Data.ByteString.Lazy.Char8 as LBS(ByteString)+import qualified Data.Text as T+import qualified Data.Text.Lazy as TL import Foreign.Ptr(Ptr)  import Text.Regex.Base(MatchArray,MatchOffset,MatchLength)@@ -82,6 +85,8 @@ {-# SPECIALIZE execMatch :: Regex -> Position -> Char -> (Seq Char) -> [MatchArray] #-} {-# SPECIALIZE execMatch :: Regex -> Position -> Char -> SBS.ByteString -> [MatchArray] #-} {-# SPECIALIZE execMatch :: Regex -> Position -> Char -> LBS.ByteString -> [MatchArray] #-}+{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> T.Text -> [MatchArray] #-}+{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> TL.Text -> [MatchArray] #-} execMatch :: Uncons text => Regex -> Position -> Char -> text -> [MatchArray] execMatch r@(Regex { regex_dfa = DFA {d_id=didIn,d_dt=dtIn}                    , regex_init = startState@@ -309,7 +314,7 @@           earlyWin <- readSTRef (mq_earliest winQ)           if earlyWin < earlyStart             then do-              winners <- fmap (foldl' (\ rest ws -> ws : rest) []) $+              winners <- fmap (List.foldl' (\ rest ws -> ws : rest) []) $                            getMQ earlyStart winQ               writeSTRef storeNext (next s2 s1 did' dt' (succ offset) prev' input')               mapM (tagsToGroupsST aGroups) winners@@ -393,7 +398,7 @@           putMQ (WScratch newerPos) winQ          finalizeWinners = do-          winners <- fmap (foldl' (\ rest mqa -> mqa_ws mqa : rest) []) $+          winners <- fmap (List.foldl' (\ rest mqa -> mqa_ws mqa : rest) []) $                        readSTRef (mq_list winQ) -- reverses the winner list           resetMQ winQ           writeSTRef storeNext (return [])@@ -726,8 +731,8 @@ --  b2 <- getBounds s2 --  when (b1/=b2) (error ("\n\nWTF copySTU: "++show (b1,b2)))   ST $ \s1# ->-    case sizeofMutableByteArray# msource        of { n# ->-    case memcpyST mdest msource n# s1# of { (# s2#, _ #) ->+    case getSizeofMutableByteArray# msource s1# of { (# s1'#, n# #) ->+    case memcpyST mdest msource n# s1'# of { (# s2#, _ #) ->     (# s2#, () #) }} {- -- #else /* !__GLASGOW_HASKELL__ */
lib/Text/Regex/TDFA/NewDFA/Engine_FA.hs view
@@ -17,7 +17,7 @@  import GHC.Arr(STArray(..)) import GHC.ST(ST(..))-import GHC.Exts(MutableByteArray#,RealWorld,Int#,sizeofMutableByteArray#,unsafeCoerce#,State#)+import GHC.Exts(MutableByteArray#,RealWorld,Int#,getSizeofMutableByteArray#,unsafeCoerce#,State#)  import Prelude hiding ((!!)) import Control.Monad(when,unless,forM,forM_,liftM2,foldM)@@ -622,8 +622,8 @@ --  b2 <- getBounds s2 --  when (b1/=b2) (error ("\n\nWTF copySTU: "++show (b1,b2)))   ST $ \s1# ->-    case sizeofMutableByteArray# msource        of { n# ->-    case memcpyST mdest msource n# s1# of { (# s2#, _ #) ->+    case getSizeofMutableByteArray# msource s1# of { (# s1'#, n# #) ->+    case memcpyST mdest msource n# s1'# of { (# s2#, _ #) ->     (# s2#, () #) }} {- -- #else /* !__GLASGOW_HASKELL__ */
lib/Text/Regex/TDFA/NewDFA/Engine_NC.hs view
@@ -18,6 +18,8 @@ import Data.Sequence(Seq) import qualified Data.ByteString.Char8 as SBS(ByteString) import qualified Data.ByteString.Lazy.Char8 as LBS(ByteString)+import qualified Data.Text as T+import qualified Data.Text.Lazy as TL  import Text.Regex.Base(MatchArray,MatchOffset,MatchLength) import qualified Text.Regex.TDFA.IntArrTrieSet as Trie(lookupAsc)@@ -44,6 +46,8 @@ {-# SPECIALIZE execMatch :: Regex -> Position -> Char -> (Seq Char) -> [MatchArray] #-} {-# SPECIALIZE execMatch :: Regex -> Position -> Char -> SBS.ByteString -> [MatchArray] #-} {-# SPECIALIZE execMatch :: Regex -> Position -> Char -> LBS.ByteString -> [MatchArray] #-}+{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> T.Text -> [MatchArray] #-}+{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> TL.Text -> [MatchArray] #-} execMatch :: Uncons text => Regex -> Position -> Char -> text -> [MatchArray] execMatch (Regex { regex_dfa = (DFA {d_id=didIn,d_dt=dtIn})                  , regex_init = startState
lib/Text/Regex/TDFA/NewDFA/Engine_NC_FA.hs view
@@ -16,6 +16,8 @@ import Data.Sequence(Seq) import qualified Data.ByteString.Char8 as SBS(ByteString) import qualified Data.ByteString.Lazy.Char8 as LBS(ByteString)+import qualified Data.Text as T+import qualified Data.Text.Lazy as TL  import Text.Regex.Base(MatchArray,MatchOffset,MatchLength) import Text.Regex.TDFA.Common hiding (indent)@@ -31,6 +33,8 @@ {-# SPECIALIZE execMatch :: Regex -> Position -> Char -> (Seq Char) -> [MatchArray] #-} {-# SPECIALIZE execMatch :: Regex -> Position -> Char -> SBS.ByteString -> [MatchArray] #-} {-# SPECIALIZE execMatch :: Regex -> Position -> Char -> LBS.ByteString -> [MatchArray] #-}+{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> T.Text -> [MatchArray] #-}+{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> TL.Text -> [MatchArray] #-} execMatch :: Uncons text => Regex -> Position -> Char -> text -> [MatchArray] execMatch (Regex { regex_dfa = DFA {d_dt=dtIn} })           offsetIn _prevIn inputIn = S.runST goNext where
lib/Text/Regex/TDFA/NewDFA/Tester.hs view
@@ -9,6 +9,8 @@ import Data.Sequence(Seq) import qualified Data.ByteString.Char8 as SBS(ByteString) import qualified Data.ByteString.Lazy.Char8 as LBS(ByteString)+import qualified Data.Text as T+import qualified Data.Text.Lazy as TL  import Text.Regex.Base() import Text.Regex.TDFA.Common hiding (indent)@@ -19,6 +21,8 @@ {-# SPECIALIZE matchTest :: Regex -> (Seq Char) -> Bool #-} {-# SPECIALIZE matchTest :: Regex -> SBS.ByteString -> Bool #-} {-# SPECIALIZE matchTest :: Regex -> LBS.ByteString -> Bool #-}+{-# SPECIALIZE matchTest :: Regex -> T.Text -> Bool #-}+{-# SPECIALIZE matchTest :: Regex -> TL.Text -> Bool #-} matchTest :: Uncons text => Regex -> text -> Bool matchTest (Regex { regex_dfa = dfaIn                  , regex_isFrontAnchored = ifa } )
lib/Text/Regex/TDFA/TDFA.hs view
@@ -18,7 +18,7 @@ import qualified Data.IntMap.CharMap2 as Map(empty) --import Data.IntSet(IntSet) import qualified Data.IntSet as ISet(empty,singleton,null)-import Data.List(foldl')+import qualified Data.List as List import qualified Data.Map (Map,empty,member,insert,elems) import Data.Sequence as S((|>),{-viewl,ViewL(..)-}) @@ -165,7 +165,7 @@     if i `Data.Map.member` old       then old       else let new = Data.Map.insert i d old-           in foldl' seen new (flattenDT dt)+           in List.foldl' seen new (flattenDT dt)  -- Get all trans_many states flattenDT :: DT -> [DFA]@@ -223,7 +223,7 @@ bestTrans aTagOP (f:fs) | null fs = canonical f                         | otherwise = answer -- if null toDisplay then answer else trace toDisplay answer  where-  answer = foldl' pick (canonical f) fs+  answer = List.foldl' pick (canonical f) fs   {- toDisplay | null fs = ""                | otherwise = unlines $ "bestTrans" : show (answer) : "from among" : concatMap (\x -> [show x, show (toInstructions (snd x))]) (f:fs) -}   canonical :: TagCommand -> (DoPa,Instructions)
lib/Text/Regex/TDFA/TNFA.hs view
@@ -40,7 +40,7 @@ import Control.Monad.State(State,runState,execState,get,put,modify) import Data.Array.IArray(Array,array) import Data.Char(toLower,toUpper,isAlpha,ord)-import Data.List(foldl')+import qualified Data.List as List import Data.IntMap (IntMap) import qualified Data.IntMap as IMap(toAscList,null,unionWith,singleton,fromList,fromDistinctAscList) import Data.IntMap.CharMap2(CharMap(..))@@ -139,7 +139,7 @@ -- processing Or. applyNullViews :: NullView -> QT -> QT applyNullViews [] win = win-applyNullViews nvs win = foldl' (dominate win) qtlose (reverse $ cleanNullView nvs) where+applyNullViews nvs win = List.foldl' (dominate win) qtlose (reverse $ cleanNullView nvs)  -- This is used to prefer to view "win" through NullView.  Losing is -- replaced by the plain win.  This is employed by Star patterns to@@ -147,7 +147,7 @@ -- skipping the NullView occurs if the match fails. preferNullViews :: NullView -> QT -> QT preferNullViews [] win = win-preferNullViews nvs win = foldl' (dominate win) win (reverse $ cleanNullView nvs) where+preferNullViews nvs win = List.foldl' (dominate win) win (reverse $ cleanNullView nvs)  {- dominate is common to applyNullViews and preferNullViews above.
regex-tdfa.cabal view
@@ -1,6 +1,6 @@-cabal-version:          1.24+cabal-version:          2.0 name:                   regex-tdfa-version:                1.3.2.4+version:                1.3.2.5  build-Type:             Simple license:                BSD3@@ -28,7 +28,7 @@  tested-with:   GHC == 9.12.2-  GHC == 9.10.2+  GHC == 9.10.3   GHC == 9.8.4   GHC == 9.6.7   GHC == 9.4.8@@ -48,7 +48,7 @@ source-repository this   type:                git   location:            https://github.com/haskell-hvr/regex-tdfa.git-  tag:                 v1.3.2.4+  tag:                 v1.3.2.5  flag force-O2   default: False@@ -92,12 +92,14 @@                         Text.Regex.TDFA.Text                         Text.Regex.TDFA.Text.Lazy +  autogen-modules:      Paths_regex_tdfa   other-modules:        Paths_regex_tdfa    build-depends:        array              >= 0.5    && < 0.6                       , base               >= 4.9    && < 5                       , bytestring         >= 0.10   && < 0.13                       , containers         >= 0.5    && < 1+                          -- containers >= 0.5.11.0 (GHC 8.4) will allow to drop some #if                       , mtl                >= 2.1.3  && < 2.4                       , parsec             == 3.1.*                       , regex-base         == 0.94.*@@ -146,11 +148,8 @@   build-depends:        array                       , base                       , bytestring-                      , containers                       , filepath-                      , mtl                       , regex-base-                      , text    -- component-specific dependencies not inherited via 'regex-tdfa'                       , directory          >= 1.1.0  && < 1.4@@ -163,10 +162,9 @@                         Rank2Types   other-extensions:     GeneralizedNewtypeDeriving -  ghc-options:          -Wall -funbox-strict-fields--  if impl(ghc >= 8.0)-    ghc-options:        -Wcompat+  ghc-options:          -funbox-strict-fields+                        -Wall+                        -Wcompat    if flag(force-O2)     ghc-options:        -O2@@ -177,8 +175,7 @@   main-is:        DocTestMain.hs    build-depends:-      base-    , regex-tdfa+      base             >= 4.9    && < 5     , doctest-parallel >= 0.2.2         -- doctest-parallel-0.2.2 is the first to filter out autogen-modules 
test/Main.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MonoLocalBinds             #-} -#if __GLASGOW_HASKELL__ >= 902+#if __GLASGOW_HASKELL__ >= 900 {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} #endif