diff --git a/benchmarks/haskell/Benchmarks/FileWrite.hs b/benchmarks/haskell/Benchmarks/FileWrite.hs index b56392fc2..be2c67dd3 100644 --- a/benchmarks/haskell/Benchmarks/FileWrite.hs +++ b/benchmarks/haskell/Benchmarks/FileWrite.hs @@ -15,11 +15,10 @@ module Benchmarks.FileWrite import Control.DeepSeq (NFData, deepseq) import Data.Bifunctor (first) import Data.List (intercalate, intersperse) -import Data.Semigroup ((<>)) import Data.String (fromString) import Data.Text (StrictText) import Data.Text.Internal.Lazy (LazyText, defaultChunkSize) -import System.IO (Handle, Newline(CRLF,LF), NewlineMode(NewlineMode), BufferMode(NoBuffering,LineBuffering,BlockBuffering), hSetBuffering, hSetNewlineMode) +import System.IO (Handle, Newline(CRLF,LF), NewlineMode(NewlineMode), BufferMode(..), hSetBuffering, hSetNewlineMode) import Test.Tasty.Bench (Benchmark, bgroup, bench, whnfAppIO) import qualified Data.Text as T import qualified Data.Text.IO as T @@ -112,11 +111,15 @@ mkFileWriteBenchmarks mkSinkNRemove = do #endif where - lazy, lazyNewlines, lazySmallChunks, lazySmallChunksNewlines :: (String, StrictText -> LazyText) + lazy, lazyNewlines :: (String, StrictText -> LazyText) lazy = ("lazy", L.fromChunks . T.chunksOf defaultChunkSize) lazyNewlines = ("lazy many newlines", snd lazy . snd strictNewlines) + +#ifdef ExtendedBenchmarks + lazySmallChunks, lazySmallChunksNewlines :: (String, StrictText -> LazyText) lazySmallChunks = ("lazy small chunks", L.fromChunks . T.chunksOf 10) lazySmallChunksNewlines = ("lazy small chunks many newlines", snd lazySmallChunks . snd strictNewlines) +#endif strict, strictNewlines :: (String, StrictText -> StrictText) strict = ("strict", id) diff --git a/benchmarks/haskell/Benchmarks/Micro.hs b/benchmarks/haskell/Benchmarks/Micro.hs index 511e17faa..8a19f1d97 100644 --- a/benchmarks/haskell/Benchmarks/Micro.hs +++ b/benchmarks/haskell/Benchmarks/Micro.hs @@ -2,6 +2,7 @@ module Benchmarks.Micro (benchmark) where +import qualified Data.List.NonEmpty as NE import qualified Data.Text.Lazy as TL import qualified Data.Text as T import Test.Tasty.Bench (Benchmark, Benchmarkable, bgroup, bcompareWithin, bench, nf) @@ -9,7 +10,7 @@ import Test.Tasty.Bench (Benchmark, Benchmarkable, bgroup, bcompareWithin, bench benchmark :: Benchmark benchmark = bgroup "Micro" [ blinear "lazy-inits--last" 500000 2 0.1 $ \len -> - nf (last . TL.inits) (chunks len) + nf (NE.last . TL.initsNE) (chunks len) , blinear "lazy-inits--map-take1" 500000 2 0.1 $ \len -> nf (map (TL.take 1) . TL.inits) (chunks len) ] diff --git a/benchmarks/haskell/Benchmarks/Programs/Fold.hs b/benchmarks/haskell/Benchmarks/Programs/Fold.hs index a92510748..6584e8f49 100644 --- a/benchmarks/haskell/Benchmarks/Programs/Fold.hs +++ b/benchmarks/haskell/Benchmarks/Programs/Fold.hs @@ -17,8 +17,9 @@ module Benchmarks.Programs.Fold ( benchmark ) where -import Data.List (foldl') +import Data.Foldable (Foldable(..)) import Data.List (intersperse) +import Prelude hiding (Foldable(..)) import System.IO (Handle) import Test.Tasty.Bench (Benchmark, bench, whnfIO) import qualified Data.Text as T @@ -29,7 +30,7 @@ import qualified Data.Text.Lazy.IO as TL benchmark :: FilePath -> Handle -> Benchmark benchmark i o = - bench "Fold" $ whnfIO $ T.readFile i >>= TL.hPutStr o . fold 80 + bench "Fold" $ whnfIO $ T.readFile i >>= TL.hPutStr o . foldText 80 -- | We represent a paragraph by a word list -- @@ -37,8 +38,8 @@ type Paragraph = [T.Text] -- | Fold a text -- -fold :: Int -> T.Text -> TL.Text -fold maxWidth = TLB.toLazyText . mconcat . +foldText :: Int -> T.Text -> TL.Text +foldText maxWidth = TLB.toLazyText . mconcat . intersperse "\n\n" . map (foldParagraph maxWidth) . paragraphs -- | Fold a paragraph diff --git a/benchmarks/haskell/Benchmarks/ReadNumbers.hs b/benchmarks/haskell/Benchmarks/ReadNumbers.hs index 17e796b69..ae7139c24 100644 --- a/benchmarks/haskell/Benchmarks/ReadNumbers.hs +++ b/benchmarks/haskell/Benchmarks/ReadNumbers.hs @@ -21,8 +21,9 @@ module Benchmarks.ReadNumbers , benchmark ) where +import Data.Foldable (Foldable(..)) +import Prelude hiding (Foldable(..)) import Test.Tasty.Bench (Benchmark, bgroup, bench, whnf) -import Data.List (foldl') import qualified Data.Text as T import qualified Data.Text.IO as T import qualified Data.Text.Lazy as TL diff --git a/benchmarks/haskell/Benchmarks/WordFrequencies.hs b/benchmarks/haskell/Benchmarks/WordFrequencies.hs index 9c0dae7c1..e577da71b 100644 --- a/benchmarks/haskell/Benchmarks/WordFrequencies.hs +++ b/benchmarks/haskell/Benchmarks/WordFrequencies.hs @@ -13,9 +13,10 @@ module Benchmarks.WordFrequencies , benchmark ) where -import Test.Tasty.Bench (Benchmark, bench, bgroup, whnf) -import Data.List (foldl') +import Data.Foldable (Foldable(..)) import Data.Map (Map) +import Prelude hiding (Foldable(..)) +import Test.Tasty.Bench (Benchmark, bench, bgroup, whnf) import qualified Data.Map as M import qualified Data.Text as T import qualified Data.Text.IO as T diff --git a/src/Data/Text/Encoding/Error.hs b/src/Data/Text/Encoding/Error.hs index ea9e09974..5db52b5cb 100644 --- a/src/Data/Text/Encoding/Error.hs +++ b/src/Data/Text/Encoding/Error.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE CPP, DeriveDataTypeable #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} -- | -- Module : Data.Text.Encoding.Error @@ -36,7 +36,6 @@ module Data.Text.Encoding.Error import Control.DeepSeq (NFData (..)) import Control.Exception (Exception, throw) -import Data.Typeable (Typeable) import Data.Word (Word8) import Numeric (showHex) @@ -74,7 +73,7 @@ data UnicodeException = | EncodeError String (Maybe Char) -- ^ Tried to encode a character that could not be represented -- under the given encoding, or ran out of input in mid-encode. - deriving (Eq, Typeable) + deriving (Eq) {-# DEPRECATED EncodeError "This constructor is never used, and will be removed." #-} diff --git a/src/Data/Text/Internal.hs b/src/Data/Text/Internal.hs index c71b1edec..b88b60682 100644 --- a/src/Data/Text/Internal.hs +++ b/src/Data/Text/Internal.hs @@ -1,6 +1,5 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE CPP #-} -{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE UnboxedTuples #-} {-# OPTIONS_HADDOCK not-home #-} @@ -58,7 +57,6 @@ import Control.Monad.ST (ST, runST) import Data.Bits import Data.Int (Int32, Int64) import Data.Text.Internal.Unsafe.Char (ord, unsafeWrite) -import Data.Typeable (Typeable) import qualified Data.Text.Array as A -- | A space efficient, packed, unboxed Unicode text type. @@ -66,7 +64,6 @@ data Text = Text {-# UNPACK #-} !A.Array -- ^ bytearray encoded as UTF-8 {-# UNPACK #-} !Int -- ^ offset in bytes (not in Char!), pointing to a start of UTF-8 sequence {-# UNPACK #-} !Int -- ^ length in bytes (not in Char!), pointing to an end of UTF-8 sequence - deriving (Typeable) -- | Type synonym for the strict flavour of 'Text'. type StrictText = Text diff --git a/src/Data/Text/Internal/Lazy.hs b/src/Data/Text/Internal/Lazy.hs index c66d13fe4..d57d98964 100644 --- a/src/Data/Text/Internal/Lazy.hs +++ b/src/Data/Text/Internal/Lazy.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE BangPatterns, DeriveDataTypeable #-} +{-# LANGUAGE BangPatterns #-} {-# OPTIONS_HADDOCK not-home #-} -- | @@ -43,7 +43,6 @@ module Data.Text.Internal.Lazy import Data.Bits (shiftL) import Data.Text () -import Data.Typeable (Typeable) import Foreign.Storable (sizeOf) import qualified Data.Text.Array as A import qualified Data.Text.Internal as T @@ -55,7 +54,6 @@ data Text = Empty -- @since 2.1.2 | Chunk {-# UNPACK #-} !T.Text Text -- ^ Chunks must be non-empty, this invariant is not checked. - deriving (Typeable) -- | Type synonym for the lazy flavour of 'Text'. type LazyText = Text diff --git a/src/Data/Text/Lazy/Builder/RealFloat.hs b/src/Data/Text/Lazy/Builder/RealFloat.hs index df6332263..bb8b2e3a2 100644 --- a/src/Data/Text/Lazy/Builder/RealFloat.hs +++ b/src/Data/Text/Lazy/Builder/RealFloat.hs @@ -1,6 +1,9 @@ {-# LANGUAGE CPP, OverloadedStrings #-} {-# LANGUAGE Trustworthy #-} +{-# OPTIONS_GHC -Wno-unrecognised-warning-flags #-} +{-# OPTIONS_GHC -Wno-x-partial #-} + -- | -- Module: Data.Text.Lazy.Builder.RealFloat -- Copyright: (c) The University of Glasgow 1994-2002 diff --git a/src/Data/Text/Lazy/Internal.hs b/src/Data/Text/Lazy/Internal.hs index 4f07f0321..b2675c6f6 100644 --- a/src/Data/Text/Lazy/Internal.hs +++ b/src/Data/Text/Lazy/Internal.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE BangPatterns, DeriveDataTypeable #-} -- | -- Module : Data.Text.Lazy.Internal -- Copyright : (c) 2013 Bryan O'Sullivan diff --git a/tests/Tests/Properties/Substrings.hs b/tests/Tests/Properties/Substrings.hs index 1c39fabe2..df0a9b9e5 100644 --- a/tests/Tests/Properties/Substrings.hs +++ b/tests/Tests/Properties/Substrings.hs @@ -229,9 +229,8 @@ split p xs = loop xs (l, []) -> [l] (l, _ : s') -> l : loop s' -t_chunksOf_same_lengths k = conjoin . map ((===k) . T.length) . ini . T.chunksOf k - where ini [] = [] - ini xs = init xs +t_chunksOf_same_lengths k = + conjoin . map ((===k) . T.length) . drop 1 . reverse . T.chunksOf k t_chunksOf_length k t = len === T.length t .||. property (k <= 0 && len == 0) where len = L.sum . L.map T.length $ T.chunksOf k t diff --git a/tests/Tests/Properties/Transcoding.hs b/tests/Tests/Properties/Transcoding.hs index bf8d1ee87..38e799c71 100644 --- a/tests/Tests/Properties/Transcoding.hs +++ b/tests/Tests/Properties/Transcoding.hs @@ -1,7 +1,10 @@ -- | Tests for encoding and decoding {-# LANGUAGE CPP, OverloadedStrings, ScopedTypeVariables #-} -{-# OPTIONS_GHC -fno-warn-missing-signatures #-} +{-# OPTIONS_GHC -Wno-missing-signatures #-} +{-# OPTIONS_GHC -Wno-unrecognised-warning-flags #-} +{-# OPTIONS_GHC -Wno-x-partial #-} + module Tests.Properties.Transcoding ( testTranscoding ) where