Skip to content

Commit b0aad38

Browse files
committed
v0.95.0.1: Drop support for GHC 7, make Prelude imports explicit
1 parent 49b52ea commit b0aad38

File tree

10 files changed

+126
-53
lines changed

10 files changed

+126
-53
lines changed

ChangeLog.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
See also http://pvp.haskell.org/faq
1+
## 0.95.0.1
2+
3+
_2025-03-02 Andreas Abel_
4+
5+
- Drop support for GHC 7
6+
- Make `Prelude` imports explicit, add `LANGUAGE NoImplicitPrelude`
7+
- Make upper bounds of dependencies major-major (all are shipped with GHC)
8+
- Tested with GHC 8.0 - 9.12.1
29

310
## 0.95.0.0 revision 6
411

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[![Hackage version](https://img.shields.io/hackage/v/regex-pcre.svg?label=Hackage&color=informational)](http://hackage.haskell.org/package/regex-pcre)
2+
[![Stackage Nightly](http://stackage.org/package/regex-pcre/badge/nightly)](http://stackage.org/nightly/package/regex-pcre)
3+
[![Stackage LTS](http://stackage.org/package/regex-pcre/badge/lts)](http://stackage.org/lts/package/regex-pcre)
4+
[![Haskell-CI](https://github.com/haskell-hvr/regex-pcre/actions/workflows/haskell-ci.yml/badge.svg?branch=master&event=push)](https://github.com/haskell-hvr/regex-pcre/actions/workflows/haskell-ci.yml)
5+
[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
6+
regex-pcre
7+
==========
8+
9+
Backend for `regex-base` via binding to PCRE library.
10+
11+
[Documentation](https://hackage.haskell.org/package/regex-pcre/docs/Text-Regex-PCRE.html) on hackage.
12+
13+
Binding to PCRE2 is in [`regex-pcre2`](https://hackage.haskell.org/package/regex-pcre2).

Setup.hs

Lines changed: 0 additions & 2 deletions
This file was deleted.

regex-pcre.cabal

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
Cabal-Version: 1.12
1+
Cabal-Version: 1.24
22
Name: regex-pcre
3-
Version: 0.95.0.0
4-
x-revision: 6
3+
Version: 0.95.0.1
54

65
build-type: Simple
76
license: BSD3
@@ -19,8 +18,9 @@ description:
1918
.
2019
See also <https://wiki.haskell.org/Regular_expressions> for more information.
2120

22-
extra-source-files:
21+
extra-doc-files:
2322
ChangeLog.md
23+
README.md
2424

2525
tested-with:
2626
GHC == 9.12.1
@@ -49,7 +49,7 @@ source-repository head
4949
source-repository this
5050
type: git
5151
location: https://github.com/haskell-hvr/regex-pcre.git
52-
tag: v0.95.0.0-r6
52+
tag: v0.95.0.1
5353

5454
library
5555
hs-source-dirs: src
@@ -64,8 +64,10 @@ library
6464
other-modules:
6565
Paths_regex_pcre
6666

67-
default-language: Haskell2010
67+
default-language:
68+
Haskell2010
6869
default-extensions:
70+
NoImplicitPrelude
6971
MultiParamTypeClasses
7072
FunctionalDependencies
7173
ForeignFunctionInterface
@@ -75,21 +77,18 @@ library
7577
TypeSynonymInstances
7678
FlexibleInstances
7779

78-
build-depends: regex-base == 0.94.*
79-
, base >= 4.3 && < 5
80-
, containers >= 0.4 && < 0.8
81-
, bytestring >= 0.9 && < 0.13
82-
, array >= 0.3 && < 0.6
83-
84-
if !impl(ghc >= 8)
85-
build-depends: fail == 4.9.*
80+
build-depends:
81+
regex-base == 0.94.*
82+
, base >= 4.9 && < 5
83+
, containers >= 0.5 && < 1
84+
, bytestring >= 0.10 && < 1
85+
, array >= 0.5 && < 1
8686

8787
if flag(pkg-config)
8888
pkgconfig-depends: libpcre
8989
else
9090
extra-libraries: pcre
9191

9292
ghc-options:
93-
-O2
94-
-Wall -fno-warn-unused-imports
95-
-- -Wcompat -- options cannot be changed in a revision
93+
-Wall
94+
-Wcompat

src/Text/Regex/PCRE.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module Text.Regex.PCRE(getVersion_Text_Regex_PCRE
3030
-- ** Wrap, for '=~' and '=~~', types and constants
3131
,module Text.Regex.PCRE.Wrap) where
3232

33-
import Prelude hiding (fail)
33+
import Prelude ()
3434

3535
import Text.Regex.PCRE.Wrap(Regex, CompOption(CompOption), ExecOption(ExecOption), (=~), (=~~),
3636
unusedOffset, getNumSubs, configUTF8, getVersion,
@@ -44,7 +44,7 @@ import Text.Regex.PCRE.String()
4444
import Text.Regex.PCRE.Sequence()
4545
import Text.Regex.PCRE.ByteString()
4646
import Text.Regex.PCRE.ByteString.Lazy()
47-
import Data.Version(Version(..))
47+
import Data.Version(Version)
4848
import Text.Regex.Base
4949
import qualified Paths_regex_pcre
5050

src/Text/Regex/PCRE/ByteString.hs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# OPTIONS_GHC -fno-warn-orphans #-}
1+
{-# OPTIONS_GHC -Wno-orphans #-}
22
{-|
33
This exports instances of the high level API and the medium level
44
API of 'compile','execute', and 'regexec'.
@@ -45,7 +45,16 @@ module Text.Regex.PCRE.ByteString(
4545
execPartial
4646
) where
4747

48-
import Prelude hiding (fail)
48+
import Prelude
49+
( Either(Left,Right), either
50+
, Int, (-), fromIntegral, pred
51+
, IO, (>>=), return
52+
, Maybe(Nothing,Just)
53+
, Show(show)
54+
, String
55+
, ($), (.), (==), (&&), otherwise, not
56+
, (++), map, length
57+
)
4958
import Control.Monad.Fail (MonadFail(fail))
5059

5160
import Text.Regex.PCRE.Wrap -- all

src/Text/Regex/PCRE/ByteString/Lazy.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{-# OPTIONS_GHC -fno-warn-orphans #-}
1+
{-# OPTIONS_GHC -Wno-orphans #-}
2+
23
{-|
34
This exports instances of the high level API and the medium level
45
API of 'compile','execute', and 'regexec'.
@@ -45,7 +46,16 @@ module Text.Regex.PCRE.ByteString.Lazy(
4546
execPartial
4647
) where
4748

48-
import Prelude hiding (fail)
49+
import Prelude
50+
( Either(Left,Right), either
51+
, Int
52+
, IO, (>>=), return
53+
, Maybe(Nothing,Just)
54+
, Show(show)
55+
, String
56+
, ($), (.), (==), (&&), otherwise, not
57+
, (++), map
58+
)
4959
import Control.Monad.Fail (MonadFail(fail))
5060

5161
import Text.Regex.PCRE.Wrap -- all

src/Text/Regex/PCRE/Sequence.hs

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,19 @@ module Text.Regex.PCRE.Sequence(
4545
execPartial
4646
) where
4747

48-
import Prelude hiding (fail)
48+
import Prelude
49+
( Bool(False)
50+
, Char
51+
, Either(Left,Right), either
52+
, IO, (>>), (>>=), return
53+
, Int, (-), fromIntegral, pred
54+
, Maybe(Nothing,Just)
55+
, Show(show)
56+
, String
57+
, ($), (.), seq, undefined
58+
, (==), otherwise
59+
, (++), length, map
60+
)
4961
import Control.Monad.Fail (MonadFail(fail))
5062

5163
import Text.Regex.PCRE.Wrap -- all
@@ -54,12 +66,20 @@ import Data.Array(Array,listArray)
5466
import System.IO.Unsafe(unsafePerformIO)
5567
import Text.Regex.Base.RegexLike(RegexMaker(..),RegexLike(..),RegexContext(..),MatchLength,MatchOffset,Extract(..))
5668
import Text.Regex.Base.Impl(polymatch,polymatchM)
57-
import Data.Sequence as S hiding (length)
69+
import Data.Sequence as S
70+
( Seq,
71+
empty,
72+
singleton,
73+
viewl,
74+
viewr,
75+
(|>),
76+
ViewL((:<), EmptyL),
77+
ViewR((:>), EmptyR) )
5878
import qualified Data.Sequence as S (length)
59-
import Foreign.C.String
60-
import Foreign.Marshal.Array
61-
import Foreign.Marshal.Alloc
62-
import Foreign.Storable
79+
import Foreign.C.String ( castCharToCChar, CString, CStringLen )
80+
import Foreign.Marshal.Array ( advancePtr )
81+
import Foreign.Marshal.Alloc ( allocaBytes )
82+
import Foreign.Storable ( Storable(poke) )
6383

6484
instance RegexContext Regex (Seq Char) (Seq Char) where
6585
match = polymatch
@@ -80,9 +100,9 @@ instance RegexLike Regex (Seq Char) where
80100
withSeq str (wrapTest 0 regex) >>= unwrap
81101
matchOnce regex str = unsafePerformIO $
82102
execute regex str >>= unwrap
83-
matchAll regex str = unsafePerformIO $
103+
matchAll regex str = unsafePerformIO $
84104
withSeq str (wrapMatchAll regex) >>= unwrap
85-
matchCount regex str = unsafePerformIO $
105+
matchCount regex str = unsafePerformIO $
86106
withSeq str (wrapCount regex) >>= unwrap
87107

88108
-- | Compiles a regular expression
@@ -104,7 +124,7 @@ execute regex str = do
104124
case maybeStartEnd of
105125
Right Nothing -> return (Right Nothing)
106126
-- Right (Just []) -> fail "got [] back!" -- should never happen
107-
Right (Just parts) ->
127+
Right (Just parts) ->
108128
return . Right . Just . listArray (0,pred (length parts))
109129
. map (\(s,e)->(fromIntegral s, fromIntegral (e-s))) $ parts
110130
Left err -> return (Left err)
@@ -119,7 +139,7 @@ regexec regex str = do
119139
let getSub (start,stop) | start == unusedOffset = S.empty
120140
| otherwise = extract (start,stop-start) str
121141
matchedParts [] = (S.empty,S.empty,str,[]) -- no information
122-
matchedParts (matchedStartStop@(start,stop):subStartStop) =
142+
matchedParts (matchedStartStop@(start,stop):subStartStop) =
123143
(before start str
124144
,getSub matchedStartStop
125145
,after stop str

src/Text/Regex/PCRE/String.hs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,16 @@ module Text.Regex.PCRE.String(
4545
execPartial
4646
) where
4747

48-
import Prelude hiding (fail)
48+
import Prelude
49+
( Either(Left,Right), either
50+
, Int, (-), fromIntegral, pred
51+
, IO, (>>=), return
52+
, Maybe(Nothing,Just)
53+
, Show(show)
54+
, String
55+
, ($), (.), (==), otherwise
56+
, (++), drop, length, map, take
57+
)
4958
import Control.Monad.Fail (MonadFail(fail))
5059

5160
import Text.Regex.PCRE.Wrap -- all
@@ -74,9 +83,9 @@ instance RegexLike Regex String where
7483
withCStringLen str (wrapTest 0 regex) >>= unwrap
7584
matchOnce regex str = unsafePerformIO $
7685
execute regex str >>= unwrap
77-
matchAll regex str = unsafePerformIO $
86+
matchAll regex str = unsafePerformIO $
7887
withCStringLen str (wrapMatchAll regex) >>= unwrap
79-
matchCount regex str = unsafePerformIO $
88+
matchCount regex str = unsafePerformIO $
8089
withCStringLen str (wrapCount regex) >>= unwrap
8190

8291
-- | Compiles a regular expression
@@ -98,7 +107,7 @@ execute regex str = do
98107
case maybeStartEnd of
99108
Right Nothing -> return (Right Nothing)
100109
-- Right (Just []) -> fail "got [] back!" -- should never happen
101-
Right (Just parts) ->
110+
Right (Just parts) ->
102111
return . Right . Just . listArray (0,pred (length parts))
103112
. map (\(s,e)->(fromIntegral s, fromIntegral (e-s))) $ parts
104113
Left err -> return (Left err)
@@ -113,7 +122,7 @@ regexec regex str = do
113122
let getSub (start,stop) | start == unusedOffset = ""
114123
| otherwise = take (stop-start) . drop start $ str
115124
matchedParts [] = ("","",str,[]) -- no information
116-
matchedParts (matchedStartStop@(start,stop):subStartStop) =
125+
matchedParts (matchedStartStop@(start,stop):subStartStop) =
117126
(take start str
118127
,getSub matchedStartStop
119128
,drop stop str

src/Text/Regex/PCRE/Wrap.hsc

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,31 @@ module Text.Regex.PCRE.Wrap(
6969
retNoSubstring
7070
) where
7171

72-
import Prelude hiding (fail)
72+
import Prelude
73+
( Bool(False,True)
74+
, Either(Left,Right)
75+
, Eq, (==), (/=), (<)
76+
, IO, (=<<), return
77+
, Integral, Int, (*), (-), fromIntegral, succ
78+
, Maybe(Nothing,Just)
79+
, Num((+))
80+
, Show(show)
81+
, String
82+
, ($), (.), id, error, seq, undefined, otherwise
83+
, (++), mapM, replicate, zip
84+
)
7385
import Control.Monad.Fail (MonadFail(fail))
7486

7587
import Control.Monad(when)
7688
import Data.Array(Array,accumArray)
77-
import Data.Bits(Bits((.|.))) -- ((.&.),(.|.),complement))
89+
import Data.Bits(Bits((.|.)))
7890
import System.IO.Unsafe(unsafePerformIO)
79-
import Foreign(Ptr,ForeignPtr,FinalizerPtr -- ,FunPtr
91+
import Foreign(Ptr,ForeignPtr,FinalizerPtr
8092
,alloca,allocaBytes,nullPtr
8193
,peek,peekElemOff
8294
,newForeignPtr,withForeignPtr)
8395
import Foreign.C(CChar)
84-
#if __GLASGOW_HASKELL__ >= 703
8596
import Foreign.C(CInt(CInt))
86-
#else
87-
import Foreign.C(CInt)
88-
#endif
8997
import Foreign.C.String(CString,CStringLen,peekCString)
9098
import Text.Regex.Base.RegexLike(RegexOptions(..),RegexMaker(..),RegexContext(..),MatchArray,MatchOffset)
9199

@@ -181,14 +189,14 @@ nullTest' :: Ptr a -> String -> IO (Either (MatchOffset,String) b) -> IO (Either
181189
{-# INLINE nullTest' #-}
182190
nullTest' ptr msg io = do
183191
if nullPtr == ptr
184-
then return (Left (0,"Ptr parameter was nullPtr in Text.Regex.PCRE.Wrap."++msg))
192+
then return (Left (0,"Ptr parameter was nullPtr in Text.Regex.PCRE.Wrap."++msg))
185193
else io
186194

187195
nullTest :: Ptr a -> String -> IO (Either WrapError b) -> IO (Either WrapError b)
188196
{-# INLINE nullTest #-}
189197
nullTest ptr msg io = do
190198
if nullPtr == ptr
191-
then return (Left (retOk,"Ptr parameter was nullPtr in Text.Regex.PCRE.Wrap."++msg))
199+
then return (Left (retOk,"Ptr parameter was nullPtr in Text.Regex.PCRE.Wrap."++msg))
192200
else io
193201

194202
wrapRC :: ReturnCode -> IO (Either WrapError b)
@@ -264,8 +272,8 @@ wrapMatch startOffset (Regex pcre_fptr _ flags) (cstr,len) = do
264272

265273
-- | wrapMatchAll is an improvement over wrapMatch since it only
266274
-- allocates memory with allocaBytes once at the start.
267-
--
268-
--
275+
--
276+
--
269277
wrapMatchAll (Regex pcre_fptr _ flags) (cstr,len) = do
270278
nullTest cstr "wrapMatchAll cstr" $ do
271279
withForeignPtr pcre_fptr $ \regex -> do
@@ -292,7 +300,7 @@ wrapMatchAll (Regex pcre_fptr _ flags) (cstr,len) = do
292300
let acc' = acc . (toMatchArray nsub_int pairs:)
293301
case pairs of
294302
[] -> return (Right (acc' []))
295-
((s,e):_) | s==e -> if s == len
303+
((s,e):_) | s==e -> if s == len
296304
then return (Right (acc' []))
297305
else loop acc' flags' e
298306
| otherwise -> loop acc' flags e

0 commit comments

Comments
 (0)