Unverified Commit 8d1b6ff5 authored by Bodigrim's avatar Bodigrim Committed by GitHub
Browse files

Drop support of GHC < 8 (#336)

* Support only GHC >= 8.0

* Fix a build warning

* Make integer-simple flag redundant
parent 2a12940b
......@@ -44,18 +44,6 @@ jobs:
allow-failure: false
- compiler: ghc-8.0.2
allow-failure: false
- compiler: ghc-7.10.3
allow-failure: false
- compiler: ghc-7.8.4
allow-failure: false
- compiler: ghc-7.6.3
allow-failure: false
- compiler: ghc-7.4.2
allow-failure: false
- compiler: ghc-7.2.2
allow-failure: false
- compiler: ghc-7.0.4
allow-failure: false
fail-fast: false
steps:
- name: apt
......
......@@ -12,9 +12,6 @@ module Benchmarks.Builder
import Test.Tasty.Bench (Benchmark, bgroup, bench, nf)
import Data.Binary.Builder as B
import Data.ByteString.Char8 ()
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (mconcat, mempty)
#endif
import qualified Data.ByteString.Builder as Blaze
import qualified Data.ByteString as SB
import qualified Data.ByteString.Lazy as LB
......
......@@ -11,9 +11,6 @@ module Benchmarks.FileRead
( benchmark
) where
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative ((<$>))
#endif
import Test.Tasty.Bench (Benchmark, bgroup, bench, whnfIO)
import qualified Data.ByteString as SB
import qualified Data.ByteString.Lazy as LB
......
......@@ -12,9 +12,6 @@ module Benchmarks.Programs.BigTable
) where
import Test.Tasty.Bench (Benchmark, bench, whnfIO)
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (mconcat, mempty, mappend)
#endif
import Data.Text.Lazy.Builder (Builder, fromText, toLazyText)
import Data.Text.Lazy.IO (hPutStr)
import System.IO (Handle)
......
......@@ -19,9 +19,6 @@ module Benchmarks.Programs.Fold
import Data.List (foldl')
import Data.List (intersperse)
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (mempty, mappend, mconcat)
#endif
import System.IO (Handle)
import Test.Tasty.Bench (Benchmark, bench, whnfIO)
import qualified Data.Text as T
......
......@@ -18,9 +18,6 @@ module Benchmarks.Programs.Sort
) where
import Test.Tasty.Bench (Benchmark, bgroup, bench, whnfIO)
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (mconcat)
#endif
import System.IO (Handle)
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL
......
......@@ -15,9 +15,6 @@ module Benchmarks.Pure
import Control.DeepSeq (NFData (..))
import Control.Exception (evaluate)
import Test.Tasty.Bench (Benchmark, bgroup, bench, nf)
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (mappend, mempty)
#endif
import GHC.Base (Char (..), Int (..), chr#, ord#, (+#))
import GHC.Generics (Generic)
import GHC.Int (Int64)
......@@ -305,14 +302,6 @@ benchmark kind ~Env{..} =
len l _ = l + (1::Int)
short = T.pack "short"
#if !MIN_VERSION_bytestring(0,10,0)
instance NFData BS.ByteString
instance NFData BL.ByteString where
rnf BL.Empty = ()
rnf (BL.Chunk _ ts) = rnf ts
#endif
data B where
B :: NFData a => a -> B
......
packages: .
tests: True
benchmarks: True
constraints: semigroups -text -hashable -unordered-containers
{-# LANGUAGE BangPatterns, CPP, MagicHash, Rank2Types, UnboxedTuples, TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif
-- Using TemplateHaskell in text unconditionally is unacceptable, as
-- it's a GHC boot library. TemplateHaskellQuotes was added in 8.0, so
-- this would seem to be a problem. However, GHC's policy of only
-- needing to be able to compile itself from the last few releases
-- allows us to use full-fat TH on older versions, while using THQ for
-- GHC versions that may be used for bootstrapping.
#if __GLASGOW_HASKELL__ >= 800
{-# LANGUAGE TemplateHaskellQuotes #-}
#else
{-# LANGUAGE TemplateHaskell #-}
#endif
{-# LANGUAGE Trustworthy #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-- |
-- Module : Data.Text
......@@ -226,9 +215,7 @@ import qualified Data.Text.Array as A
import qualified Data.List as L
import Data.Binary (Binary(get, put))
import Data.Monoid (Monoid(..))
#if MIN_VERSION_base(4,9,0)
import Data.Semigroup (Semigroup(..))
#endif
import Data.String (IsString(..))
import qualified Data.Text.Internal.Fusion as S
import qualified Data.Text.Internal.Fusion.Common as S
......@@ -251,14 +238,10 @@ import qualified Data.Text.Lazy as L
import Data.Int (Int64)
#endif
import GHC.Base (eqInt, neInt, gtInt, geInt, ltInt, leInt)
#if MIN_VERSION_base(4,7,0)
import qualified GHC.Exts as Exts
#endif
import qualified Language.Haskell.TH.Lib as TH
import qualified Language.Haskell.TH.Syntax as TH
#if MIN_VERSION_base(4,7,0)
import Text.Printf (PrintfArg, formatArg, formatString)
#endif
-- $setup
-- >>> import Data.Text
......@@ -364,37 +347,23 @@ instance Ord Text where
instance Read Text where
readsPrec p str = [(pack x,y) | (x,y) <- readsPrec p str]
#if MIN_VERSION_base(4,9,0)
-- | Non-orphan 'Semigroup' instance only defined for
-- @base-4.9.0.0@ and later; orphan instances for older GHCs are
-- provided by
-- the [semigroups](http://hackage.haskell.org/package/semigroups)
-- package
--
-- @since 1.2.2.0
-- | @since 1.2.2.0
instance Semigroup Text where
(<>) = append
#endif
instance Monoid Text where
mempty = empty
#if MIN_VERSION_base(4,9,0)
mappend = (<>) -- future-proof definition
#else
mappend = append
#endif
mappend = (<>)
mconcat = concat
instance IsString Text where
fromString = pack
#if MIN_VERSION_base(4,7,0)
-- | @since 1.2.0.0
instance Exts.IsList Text where
type Item Text = Char
fromList = pack
toList = unpack
#endif
instance NFData Text where rnf !_ = ()
......@@ -442,13 +411,9 @@ instance TH.Lift Text where
liftTyped = TH.unsafeTExpCoerce . TH.lift
#endif
#if MIN_VERSION_base(4,7,0)
-- | Only defined for @base-4.7.0.0@ and later
--
-- @since 1.2.2.0
-- | @since 1.2.2.0
instance PrintfArg Text where
formatArg txt = formatString $ unpack txt
#endif
packConstr :: Constr
packConstr = mkConstr textDataType "pack" [] Prefix
......
......@@ -42,23 +42,16 @@ module Data.Text.Array
#if defined(ASSERTS)
import Control.Exception (assert)
import GHC.Base (sizeofByteArray#, sizeofMutableByteArray#)
#endif
#if MIN_VERSION_base(4,4,0)
import Control.Monad.ST.Unsafe (unsafeIOToST)
#else
import Control.Monad.ST (unsafeIOToST)
#endif
import Data.Bits ((.&.), xor)
import Data.Text.Internal.Unsafe (inlinePerformIO)
import Data.Text.Internal.Unsafe.Shift (shiftL, shiftR)
#if MIN_VERSION_base(4,5,0)
import Foreign.C.Types (CInt(CInt), CSize(CSize))
#else
import Foreign.C.Types (CInt, CSize)
#endif
import GHC.Base (ByteArray#, MutableByteArray#, Int(..),
indexWord16Array#, newByteArray#,
unsafeFreezeByteArray#, writeWord16Array#, sizeofByteArray#, sizeofMutableByteArray#)
unsafeFreezeByteArray#, writeWord16Array#)
import GHC.ST (ST(..), runST)
import GHC.Word (Word16(..))
import Prelude hiding (length, read)
......
{-# LANGUAGE BangPatterns, CPP, GeneralizedNewtypeDeriving, MagicHash,
UnliftedFFITypes #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif
-- |
-- Module : Data.Text.Encoding
-- Copyright : (c) 2009, 2010, 2011 Bryan O'Sullivan,
......@@ -59,11 +57,7 @@ module Data.Text.Encoding
, encodeUtf8BuilderEscaped
) where
#if MIN_VERSION_base(4,4,0)
import Control.Monad.ST.Unsafe (unsafeIOToST, unsafeSTToIO)
#else
import Control.Monad.ST (unsafeIOToST, unsafeSTToIO)
#endif
import Control.Exception (evaluate, try, throwIO, ErrorCall(ErrorCall))
import Control.Monad.ST (runST)
......@@ -79,11 +73,7 @@ import Data.Text.Internal.Unsafe.Shift (shiftR)
import Data.Text.Show ()
import Data.Text.Unsafe (unsafeDupablePerformIO)
import Data.Word (Word8, Word32)
#if MIN_VERSION_base(4,5,0)
import Foreign.C.Types (CSize(CSize))
#else
import Foreign.C.Types (CSize)
#endif
import Foreign.Marshal.Utils (with)
import Foreign.Ptr (Ptr, minusPtr, nullPtr, plusPtr)
import Foreign.Storable (Storable, peek, poke)
......
{-# LANGUAGE CPP, DeriveDataTypeable #-}
#if __GLASGOW_HASKELL__ >= 704
{-# LANGUAGE Safe #-}
#elif __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif
-- |
-- Module : Data.Text.Encoding.Error
-- Copyright : (c) Bryan O'Sullivan 2009
......
......@@ -34,11 +34,7 @@ module Data.Text.Foreign
#if defined(ASSERTS)
import Control.Exception (assert)
#endif
#if MIN_VERSION_base(4,4,0)
import Control.Monad.ST.Unsafe (unsafeIOToST)
#else
import Control.Monad.ST (unsafeIOToST)
#endif
import Data.ByteString.Unsafe (unsafePackCStringLen, unsafeUseAsCStringLen)
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import Data.Text.Internal (Text(..), empty)
......
{-# LANGUAGE BangPatterns, CPP, RecordWildCards, ScopedTypeVariables #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif
-- |
-- Module : Data.Text.IO
-- Copyright : (c) 2009, 2010 Bryan O'Sullivan,
......
......@@ -20,10 +20,6 @@
-- with the internals, as the functions here do just about nothing to
-- preserve data invariants. You have been warned!
#if defined(__GLASGOW_HASKELL__) && !defined(__HADDOCK__)
#include "MachDeps.h"
#endif
module Data.Text.Internal
(
-- * Types
......@@ -124,11 +120,11 @@ firstf _ Nothing = Nothing
-- | Checked multiplication. Calls 'error' if the result would
-- overflow.
mul :: Int -> Int -> Int
#if WORD_SIZE_IN_BITS == 64
mul a b = fromIntegral $ fromIntegral a `mul64` fromIntegral b
#else
mul a b = fromIntegral $ fromIntegral a `mul32` fromIntegral b
#endif
mul a b
| finiteBitSize (0 :: Word) == 64
= fromIntegral $ fromIntegral a `mul64` fromIntegral b
| otherwise
= fromIntegral $ fromIntegral a `mul32` fromIntegral b
{-# INLINE mul #-}
infixl 7 `mul`
......
......@@ -59,7 +59,7 @@ module Data.Text.Internal.Builder
import Control.Monad.ST (ST, runST)
import Data.Monoid (Monoid(..))
#if !MIN_VERSION_base(4,11,0) && MIN_VERSION_base(4,9,0)
#if !MIN_VERSION_base(4,11,0)
import Data.Semigroup (Semigroup(..))
#endif
import Data.Text.Internal (Text(..), safe)
......@@ -92,20 +92,14 @@ newtype Builder = Builder {
-> ST s [S.Text]
}
#if MIN_VERSION_base(4,9,0)
instance Semigroup Builder where
(<>) = append
{-# INLINE (<>) #-}
#endif
instance Monoid Builder where
mempty = empty
{-# INLINE mempty #-}
#if MIN_VERSION_base(4,9,0)
mappend = (<>) -- future-proof definition
#else
mappend = append
#endif
mappend = (<>)
{-# INLINE mappend #-}
mconcat = foldr mappend Data.Monoid.mempty
{-# INLINE mconcat #-}
......
......@@ -15,9 +15,6 @@ module Data.Text.Internal.Builder.RealFloat.Functions
) where
roundTo :: Int -> [Int] -> (Int,[Int])
#if MIN_VERSION_base(4,6,0)
roundTo d is =
case f d True is of
x@(0,_) -> x
......@@ -36,22 +33,3 @@ roundTo d is =
(c,ds) = f (n-1) (even i) xs
i' = c + i
base = 10
#else
roundTo d is =
case f d is of
x@(0,_) -> x
(1,xs) -> (1, 1:xs)
_ -> error "roundTo: bad Value"
where
f n [] = (0, replicate n 0)
f 0 (x:_) = (if x >= 5 then 1 else 0, [])
f n (i:xs)
| i' == 10 = (1,0:ds)
| otherwise = (0,i':ds)
where
(c,ds) = f (n-1) xs
i' = c + i
#endif
......@@ -22,24 +22,17 @@ module Data.Text.Internal.Unsafe
) where
import GHC.ST (ST(..))
#if defined(__GLASGOW_HASKELL__)
import GHC.IO (IO(IO))
import GHC.Base (realWorld#)
#endif
-- | Just like unsafePerformIO, but we inline it. Big performance gains as
-- it exposes lots of things to further inlining. /Very unsafe/. In
-- particular, you should do no memory allocation inside an
-- 'inlinePerformIO' block. On Hugs this is just @unsafePerformIO@.
-- 'inlinePerformIO' block.
--
{-# INLINE inlinePerformIO #-}
inlinePerformIO :: IO a -> a
#if defined(__GLASGOW_HASKELL__)
inlinePerformIO (IO m) = case m realWorld# of (# _, r #) -> r
#else
inlinePerformIO = unsafePerformIO
#endif
-- | Allow an 'ST' computation to be deferred lazily. When passed an
-- action of type 'ST' @s@ @a@, the action will only be performed when
......
{-# LANGUAGE CPP #-}
#if MIN_VERSION_base(4,5,0)
-- base-4.5.0 is 7.4, default sigs introduced in 7.2
{-# LANGUAGE DefaultSignatures #-}
#endif
{-# LANGUAGE MagicHash #-}
-- |
......@@ -25,13 +22,8 @@ module Data.Text.Internal.Unsafe.Shift
UnsafeShift(..)
) where
#if MIN_VERSION_base(4,5,0)
import qualified Data.Bits as Bits
import Data.Word
#else
import GHC.Base
import GHC.Word
#endif
-- | This is a workaround for poor optimisation in GHC 6.8.2. It
-- fails to notice constant-width shifts, and adds a test and branch
......@@ -41,60 +33,16 @@ import GHC.Word
-- greater than the size in bits of a machine Int#.
class UnsafeShift a where
shiftL :: a -> Int -> a
#if MIN_VERSION_base(4,5,0)
{-# INLINE shiftL #-}
default shiftL :: Bits.Bits a => a -> Int -> a
shiftL = Bits.unsafeShiftL
#endif
shiftR :: a -> Int -> a
#if MIN_VERSION_base(4,5,0)
{-# INLINE shiftR #-}
default shiftR :: Bits.Bits a => a -> Int -> a
shiftR = Bits.unsafeShiftR
#endif
instance UnsafeShift Word16 where
#if !MIN_VERSION_base(4,5,0)
{-# INLINE shiftL #-}
shiftL (W16# x#) (I# i#) = W16# (narrow16Word# (x# `uncheckedShiftL#` i#))
{-# INLINE shiftR #-}
shiftR (W16# x#) (I# i#) = W16# (x# `uncheckedShiftRL#` i#)
#endif
instance UnsafeShift Word32 where
#if !MIN_VERSION_base(4,5,0)
{-# INLINE shiftL #-}
shiftL (W32# x#) (I# i#) = W32# (narrow32Word# (x# `uncheckedShiftL#` i#))
{-# INLINE shiftR #-}
shiftR (W32# x#) (I# i#) = W32# (x# `uncheckedShiftRL#` i#)
#endif
instance UnsafeShift Word64 where
#if !MIN_VERSION_base(4,5,0)
{-# INLINE shiftL #-}
shiftL (W64# x#) (I# i#) = W64# (x# `uncheckedShiftL64#` i#)
{-# INLINE shiftR #-}
shiftR (W64# x#) (I# i#) = W64# (x# `uncheckedShiftRL64#` i#)
#endif
instance UnsafeShift Int where
#if !MIN_VERSION_base(4,5,0)
{-# INLINE shiftL #-}
shiftL (I# x#) (I# i#) = I# (x# `iShiftL#` i#)
{-# INLINE shiftR #-}
shiftR (I# x#) (I# i#) = I# (x# `iShiftRA#` i#)
#endif
{-
instance UnsafeShift Integer where
{-# INLINE shiftL #-}
shiftL = Bits.shiftL
{-# INLINE shiftR #-}
shiftR = Bits.shiftR
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE BangPatterns, MagicHash, CPP, TypeFamilies #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif
-- Using TemplateHaskell in text unconditionally is unacceptable, as
-- it's a GHC boot library. TemplateHaskellQuotes was added in 8.0, so
-- this would seem to be a problem. However, GHC's policy of only
-- needing to be able to compile itself from the last few releases
-- allows us to use full-fat TH on older versions, while using THQ for
-- GHC versions that may be used for bootstrapping.
#if __GLASGOW_HASKELL__ >= 800
{-# LANGUAGE TemplateHaskellQuotes #-}
#else
{-# LANGUAGE TemplateHaskell #-}
#endif
-- |
-- Module : Data.Text.Lazy
......@@ -222,9 +210,7 @@ import Data.Data (Data(gfoldl, toConstr, gunfold, dataTypeOf), constrIndex,
Constr, mkConstr, DataType, mkDataType, Fixity(Prefix))
import Data.Binary (Binary(get, put))
import Data.Monoid (Monoid(..))
#if MIN_VERSION_base(4,9,0)
import Data.Semigroup (Semigroup(..))
#endif
import Data.String (IsString(..))
import qualified Data.Text as T
import qualified Data.Text.Internal as T
......@@ -239,20 +225,12 @@ import Data.Text.Internal (firstf, safe, text)
import Data.Text.Lazy.Encoding (decodeUtf8', encodeUtf8)
import qualified Data.Text.Internal.Functions as F
import Data.Text.Internal.Lazy.Search (indices)
#if __GLASGOW_HASKELL__ >= 702
import qualified GHC.CString as GHC
#else
import qualified GHC.Base as GHC
#endif
#if MIN_VERSION_base(4,7,0)
import qualified GHC.Exts as Exts
#endif
import GHC.Prim (Addr#)
import qualified Language.Haskell.TH.Lib as TH
import qualified Language.Haskell.TH.Syntax as TH
#if MIN_VERSION_base(4,7,0)
import Text.Printf (PrintfArg, formatArg, formatString)
#endif
-- $fusion
--
......@@ -357,37 +335,23 @@ instance Show Text where
instance Read Text where
readsPrec p str = [(pack x,y) | (x,y) <- readsPrec p str]
#if MIN_VERSION_base(4,9,0)
-- | Non-orphan 'Semigroup' instance only defined for
-- @base-4.9.0.0@ and later; orphan instances for older GHCs are
-- provided by
-- the [semigroups](http://hackage.haskell.org/package/semigroups)
-- package
--
-- @since 1.2.2.0
-- | @since 1.2.2.0
instance Semigroup Text where
(<>) = append
#endif
instance Monoid Text where
mempty = empty
#if MIN_VERSION_base(4,9,0)
mappend = (<>) -- future-proof definition
#else
mappend = append
#endif
mappend = (<>)
mconcat = concat
instance IsString Text where
fromString = pack
#if MIN_VERSION_base(4,7,0)
-- | @since 1.2.0.0
instance Exts.IsList Text where
type Item Text = Char
fromList = pack
toList = unpack
#endif
instance NFData Text where
rnf Empty = ()
......@@ -427,13 +391,9 @@ instance TH.Lift Text where
liftTyped = TH.unsafeTExpCoerce . TH.lift
#endif
#if MIN_VERSION_base(4,7,0)
-- | Only defined for @base-4.7.0.0@ and later
--
-- @since 1.2.2.0
-- | @since 1.2.2.0
instance PrintfArg Text where
formatArg txt = formatString $ unpack txt
#endif
packConstr :: Constr
packConstr = mkConstr textDataType "pack" [] Prefix
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment