Skip to content

Commit a1262cd

Browse files
committed
Drop support for base < 4.18, clean up CPP
1 parent 3d9f5ed commit a1262cd

File tree

8 files changed

+1
-48
lines changed

8 files changed

+1
-48
lines changed

bytesmith.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ library
4141
Data.Bytes.Parser.Types
4242

4343
build-depends:
44-
, base >=4.12 && <5
44+
, base >=4.18 && <5
4545
, byteslice >=0.2.6 && <0.3
4646
, bytestring >=0.10.8 && <0.13
4747
, contiguous >=0.6 && <0.7

src/Data/Bytes/Parser.hs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,13 @@ cstring :: e -> CString -> Parser e s ()
258258
cstring e (Exts.Ptr ptr0) = Parser
259259
( \(# arr, off0, len0 #) s ->
260260
let go !ptr !off !len = case
261-
#if MIN_VERSION_base(4,16,0)
262261
Exts.word8ToWord#
263-
#endif
264262
(Exts.indexWord8OffAddr# ptr 0#) of
265263
0## -> (# s, (# | (# (), off, len #) #) #)
266264
c -> case len of
267265
0# -> (# s, (# e | #) #)
268266
_ -> case Exts.eqWord# c (
269-
#if MIN_VERSION_base(4,16,0)
270267
Exts.word8ToWord#
271-
#endif
272268
(Exts.indexWord8Array# arr off)) of
273269
1# -> go (Exts.plusAddr# ptr 1# ) (off +# 1# ) (len -# 1# )
274270
_ -> (# s, (# e | #) #)
@@ -593,9 +589,7 @@ unboxWord32 (Parser f) = Parser
593589
(# s1, r #) -> case r of
594590
(# e | #) -> (# s1, (# e | #) #)
595591
(# | (# W32# a, b, c #) #) -> (# s1, (# | (#
596-
#if MIN_VERSION_base(4,16,0)
597592
Exts.word32ToWord#
598-
#endif
599593
a, b, c #) #) #)
600594
)
601595
{- FOURMOLU_ENABLE -}
@@ -621,9 +615,7 @@ boxWord32 (Parser f) = Parser
621615
(# s1, r #) -> case r of
622616
(# e | #) -> (# s1, (# e | #) #)
623617
(# | (# a, b, c #) #) -> (# s1, (# | (# W32# (
624-
#if MIN_VERSION_base(4,16,0)
625618
Exts.wordToWord32#
626-
#endif
627619
a), b, c #) #) #)
628620
)
629621
{- FOURMOLU_ENABLE -}

src/Data/Bytes/Parser/BigEndian.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ module Data.Bytes.Parser.BigEndian
3838

3939
import Prelude hiding (any, fail, length, takeWhile)
4040

41-
#if MIN_VERSION_base(4,18,0)
42-
#else
43-
import Control.Applicative (liftA2)
44-
#endif
4541
import Data.Bits (unsafeShiftL, (.|.))
4642
import Data.Bytes.Parser.Internal (Parser, Result (..), swapArray128, swapArray16, swapArray256, swapArray32, swapArray64, uneffectful)
4743
import Data.Bytes.Types (Bytes (..))

src/Data/Bytes/Parser/Latin.hs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -701,11 +701,7 @@ upcastWord64Result :: Result# e Word# -> Result# e Word64
701701
{-# inline upcastWord64Result #-}
702702
upcastWord64Result (# e | #) = (# e | #)
703703
upcastWord64Result (# | (# a, b, c #) #) = (# | (# W64# (
704-
#if MIN_VERSION_base(4,17,0)
705704
Exts.wordToWord64# a
706-
#else
707-
a
708-
#endif
709705
), b, c #) #)
710706
{- FOURMOLU_ENABLE -}
711707

@@ -774,29 +770,23 @@ upcastWord16Result :: Result# e Word# -> Result# e Word16
774770
{-# inline upcastWord16Result #-}
775771
upcastWord16Result (# e | #) = (# e | #)
776772
upcastWord16Result (# | (# a, b, c #) #) = (# | (# W16# (
777-
#if MIN_VERSION_base(4,16,0)
778773
Exts.wordToWord16#
779-
#endif
780774
a), b, c #) #)
781775

782776
-- Precondition: the word is small enough
783777
upcastWord32Result :: Result# e Word# -> Result# e Word32
784778
{-# inline upcastWord32Result #-}
785779
upcastWord32Result (# e | #) = (# e | #)
786780
upcastWord32Result (# | (# a, b, c #) #) = (# | (# W32# (
787-
#if MIN_VERSION_base(4,16,0)
788781
Exts.wordToWord32#
789-
#endif
790782
a), b, c #) #)
791783

792784
-- Precondition: the word is small enough
793785
upcastWord8Result :: Result# e Word# -> Result# e Word8
794786
{-# inline upcastWord8Result #-}
795787
upcastWord8Result (# e | #) = (# e | #)
796788
upcastWord8Result (# | (# a, b, c #) #) = (# | (# W8# (
797-
#if MIN_VERSION_base(4,16,0)
798789
Exts.wordToWord8#
799-
#endif
800790
a), b, c #) #)
801791
{- FOURMOLU_ENABLE -}
802792

@@ -1188,9 +1178,7 @@ hexFixedWord32 e = Parser
11881178
(# s1, r #) -> case r of
11891179
(# err | #) -> (# s1, (# err | #) #)
11901180
(# | (# a, b, c #) #) -> (# s1, (# | (# W32# (
1191-
#if MIN_VERSION_base(4,16,0)
11921181
Exts.wordToWord32#
1193-
#endif
11941182
a), b, c #) #) #)
11951183
)
11961184
{- FOURMOLU_ENABLE -}
@@ -1239,12 +1227,7 @@ hexFixedWord64 e = Parser
12391227
(# s1, r #) -> case r of
12401228
(# err | #) -> (# s1, (# err | #) #)
12411229
(# | (# a, b, c #) #) -> (# s1, (# | (# W64# (
1242-
#if MIN_VERSION_base(4,17,0)
12431230
Exts.wordToWord64# a
1244-
#else
1245-
1246-
a
1247-
#endif
12481231
), b, c #) #) #)
12491232
)
12501233
{- FOURMOLU_ENABLE -}
@@ -1298,9 +1281,7 @@ hexFixedWord16 e = Parser
12981281
(# s1, r #) -> case r of
12991282
(# err | #) -> (# s1, (# err | #) #)
13001283
(# | (# a, b, c #) #) -> (# s1, (# | (# W16# (
1301-
#if MIN_VERSION_base(4,16,0)
13021284
Exts.wordToWord16#
1303-
#endif
13041285
a), b, c #) #) #)
13051286
)
13061287

@@ -1334,9 +1315,7 @@ hexFixedWord8 e = Parser
13341315
(# s1, r #) -> case r of
13351316
(# err | #) -> (# s1, (# err | #) #)
13361317
(# | (# a, b, c #) #) -> (# s1, (# | (# W8# (
1337-
#if MIN_VERSION_base(4,16,0)
13381318
Exts.wordToWord8#
1339-
#endif
13401319
a), b, c #) #) #)
13411320
)
13421321
{- FOURMOLU_ENABLE -}

src/Data/Bytes/Parser/LittleEndian.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ module Data.Bytes.Parser.LittleEndian
4343

4444
import Prelude hiding (any, fail, length, takeWhile)
4545

46-
#if MIN_VERSION_base(4,18,0)
47-
#else
4846
import Control.Applicative (liftA2)
49-
#endif
5047
import Data.Bits (unsafeShiftL, (.|.))
5148
import Data.Bytes.Parser.Internal (Parser, Result (..), swapArray128, swapArray16, swapArray256, swapArray32, swapArray64, uneffectful)
5249
import Data.Bytes.Types (Bytes (..))

src/Data/Bytes/Parser/Rebindable.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ module Data.Bytes.Parser.Rebindable
2525
import Data.Bytes.Parser.Internal (Parser (..))
2626
import GHC.Exts (RuntimeRep (..), TYPE)
2727
import Prelude ()
28-
29-
#if MIN_VERSION_base(4,16,0)
3028
import GHC.Exts (LiftedRep)
31-
#else
32-
type LiftedRep = 'LiftedRep
33-
#endif
3429

3530
class Bind (ra :: RuntimeRep) (rb :: RuntimeRep) where
3631
(>>=) ::

src/Data/Bytes/Parser/Utf8.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ any# e = Parser
4646
let !w0 = Exts.indexWord8Array# arr off
4747
in if | oneByteChar (W8# w0) ->
4848
(# s0, (# | (# chr# (Exts.word2Int# (
49-
#if MIN_VERSION_base(4,16,0)
5049
Exts.word8ToWord#
51-
#endif
5250
w0)), off +# 1#, len -# 1# #) #) #)
5351
| twoByteChar (W8# w0) ->
5452
if | I# len > 1

test/Main.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
{-# LANGUAGE TypeApplications #-}
88
{-# OPTIONS_GHC -fno-warn-orphans #-}
99

10-
#if MIN_VERSION_base(4,18,0)
11-
#else
12-
import Control.Applicative (liftA2)
13-
#endif
1410
import Control.Monad (replicateM)
1511
import Control.Monad.ST (runST)
1612
import Data.Bytes.Parser (Slice (Slice))

0 commit comments

Comments
 (0)