Skip to content

Commit 64c07fb

Browse files
committed
Add since annotations to newly added Text bits
1 parent 128e925 commit 64c07fb

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

lib/Text/Regex/TDFA/Text.hs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
{-|
1+
{-|
22
Module : Text.Regex.TDFA.Text
33
Copyright : Chris Kuklewicz 2007-2009, shelarcy 2012
44
License : BSD-style (see the file LICENSE)
55
6-
Maintainer : shelarcy <shelarcy@gmail.com>
7-
Stability : experimental
8-
Portability : GHC (uses text)
9-
106
This modules provides 'RegexMaker' and 'RegexLike' instances for using
117
'Text' with the TDFA backend ("Text.Regex.TDFA.NewDFA.Engine" and
12-
"Text.Regex.TDFA.NewDFA.Tester").
8+
"Text.Regex.TDFA.NewDFA.Tester").
139
1410
This exports instances of the high level API and the medium level
1511
API of 'compile','execute', and 'regexec'.
12+
13+
@since 1.3.1
1614
-}
1715
module Text.Regex.TDFA.Text(
1816
Regex
@@ -38,32 +36,38 @@ import Text.Regex.TDFA.NewDFA.Uncons(Uncons(uncons))
3836
import qualified Text.Regex.TDFA.NewDFA.Engine as Engine(execMatch)
3937
import qualified Text.Regex.TDFA.NewDFA.Tester as Tester(matchTest)
4038

39+
-- | @since 1.3.1
4140
instance Uncons T.Text where
4241
{- INLINE uncons #-}
4342
uncons = T.uncons
4443

44+
-- | @since 1.3.1
4545
instance RegexContext Regex T.Text T.Text where
4646
match = polymatch
4747
matchM = polymatchM
4848

49+
-- | @since 1.3.1
4950
instance RegexMaker Regex CompOption ExecOption T.Text where
5051
makeRegexOptsM c e source = makeRegexOptsM c e (T.unpack source)
5152

53+
-- | @since 1.3.1
5254
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> T.Text -> [MatchArray] #-}
5355
execMatch :: Uncons text => Regex -> Position -> Char -> text -> [MatchArray]
5456
execMatch = Engine.execMatch
5557

58+
-- | @since 1.3.1
5659
{-# SPECIALIZE myMatchTest :: Regex -> T.Text -> Bool #-}
5760
myMatchTest :: Uncons text => Regex -> text -> Bool
5861
myMatchTest = Tester.matchTest
5962

63+
-- | @since 1.3.1
6064
instance RegexLike Regex T.Text where
6165
matchOnce r s = listToMaybe (matchAll r s)
6266
matchAll r s = execMatch r 0 '\n' s
6367
matchCount r s = length (matchAll r' s)
6468
where r' = r { regex_execOptions = (regex_execOptions r) {captureGroups = False} }
6569
matchTest = myMatchTest
66-
matchOnceText regex source =
70+
matchOnceText regex source =
6771
fmap (\ma -> let (o,l) = ma!0
6872
in (before o source
6973
,fmap (\ol -> (extract ol source,ol)) ma
@@ -73,6 +77,7 @@ instance RegexLike Regex T.Text where
7377
map (fmap (\ol -> (extract ol source,ol)))
7478
(matchAll regex source)
7579

80+
-- | @since 1.3.1
7681
compile :: CompOption -- ^ Flags (summed together)
7782
-> ExecOption -- ^ Flags (summed together)
7883
-> T.Text -- ^ The regular expression to compile
@@ -82,11 +87,13 @@ compile compOpt execOpt txt =
8287
Left err -> Left ("parseRegex for Text.Regex.TDFA.Text failed:"++show err)
8388
Right pattern -> Right (patternToRegex pattern compOpt execOpt)
8489

90+
-- | @since 1.3.1
8591
execute :: Regex -- ^ Compiled regular expression
8692
-> T.Text -- ^ Text to match against
8793
-> Either String (Maybe MatchArray)
8894
execute r txt = Right (matchOnce r txt)
8995

96+
-- | @since 1.3.1
9097
regexec :: Regex -- ^ Compiled regular expression
9198
-> T.Text -- ^ Text to match against
9299
-> Either String (Maybe (T.Text, T.Text, T.Text, [T.Text]))

lib/Text/Regex/TDFA/Text/Lazy.hs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ Module : Text.Regex.TDFA.Text.Lazy
33
Copyright : Chris Kuklewicz 2007-2009, shelarcy 2012
44
License : BSD-style (see the file LICENSE)
55
6-
Maintainer : shelarcy <shelarcy@gmail.com>
7-
Stability : experimental
8-
Portability : GHC (uses text)
9-
106
This modules provides 'RegexMaker' and 'RegexLike' instances for using
117
'Text' with the TDFA backend ("Text.Regex.TDFA.NewDFA.Engine" and
128
"Text.Regex.TDFA.NewDFA.Tester").
139
1410
This exports instances of the high level API and the medium level
1511
API of 'compile','execute', and 'regexec'.
12+
13+
@since 1.3.1
1614
-}
1715
module Text.Regex.TDFA.Text.Lazy(
1816
Regex
@@ -38,25 +36,31 @@ import Text.Regex.TDFA.NewDFA.Uncons(Uncons(uncons))
3836
import qualified Text.Regex.TDFA.NewDFA.Engine as Engine(execMatch)
3937
import qualified Text.Regex.TDFA.NewDFA.Tester as Tester(matchTest)
4038

39+
-- | @since 1.3.1
4140
instance RegexContext Regex L.Text L.Text where
4241
match = polymatch
4342
matchM = polymatchM
4443

44+
-- | @since 1.3.1
4545
instance Uncons L.Text where
4646
{- INLINE uncons #-}
4747
uncons = L.uncons
4848

49+
-- | @since 1.3.1
4950
instance RegexMaker Regex CompOption ExecOption L.Text where
5051
makeRegexOptsM c e source = makeRegexOptsM c e (L.unpack source)
5152

53+
-- | @since 1.3.1
5254
{-# SPECIALIZE execMatch :: Regex -> Position -> Char -> L.Text -> [MatchArray] #-}
5355
execMatch :: Uncons text => Regex -> Position -> Char -> text -> [MatchArray]
5456
execMatch = Engine.execMatch
5557

58+
-- | @since 1.3.1
5659
{-# SPECIALIZE myMatchTest :: Regex -> L.Text -> Bool #-}
5760
myMatchTest :: Uncons text => Regex -> text -> Bool
5861
myMatchTest = Tester.matchTest
5962

63+
-- | @since 1.3.1
6064
instance RegexLike Regex L.Text where
6165
matchOnce r s = listToMaybe (matchAll r s)
6266
matchAll r s = execMatch r 0 '\n' s
@@ -81,6 +85,7 @@ instance RegexLike Regex L.Text where
8185
in fmap trans x : seq t' (go (off0+len0) t' xs)
8286
in go 0 source (matchAll regex source)
8387

88+
-- | @since 1.3.1
8489
compile :: CompOption -- ^ Flags (summed together)
8590
-> ExecOption -- ^ Flags (summed together)
8691
-> L.Text -- ^ The regular expression to compile
@@ -90,11 +95,13 @@ compile compOpt execOpt txt =
9095
Left err -> Left ("parseRegex for Text.Regex.TDFA.Text.Lazy failed:"++show err)
9196
Right pattern -> Right (patternToRegex pattern compOpt execOpt)
9297

98+
-- | @since 1.3.1
9399
execute :: Regex -- ^ Compiled regular expression
94100
-> L.Text -- ^ Text to match against
95101
-> Either String (Maybe MatchArray)
96102
execute r txt = Right (matchOnce r txt)
97103

104+
-- | @since 1.3.1
98105
regexec :: Regex -- ^ Compiled regular expression
99106
-> L.Text -- ^ Text to match against
100107
-> Either String (Maybe (L.Text, L.Text, L.Text, [L.Text]))

0 commit comments

Comments
 (0)