Skip to content

Fix some warnings #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions benchmarks/haskell/Benchmarks/FileWrite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/haskell/Benchmarks/Micro.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

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)

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)
]
Expand Down
9 changes: 5 additions & 4 deletions benchmarks/haskell/Benchmarks/Programs/Fold.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,16 +30,16 @@ 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
--
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
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/haskell/Benchmarks/ReadNumbers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions benchmarks/haskell/Benchmarks/WordFrequencies.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/Data/Text/Encoding/Error.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE CPP, DeriveDataTypeable #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE Safe #-}
-- |
-- Module : Data.Text.Encoding.Error
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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." #-}

Expand Down
3 changes: 0 additions & 3 deletions src/Data/Text/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UnboxedTuples #-}
{-# OPTIONS_HADDOCK not-home #-}
Expand Down Expand Up @@ -58,15 +57,13 @@ 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.
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
Expand Down
4 changes: 1 addition & 3 deletions src/Data/Text/Internal/Lazy.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE BangPatterns, DeriveDataTypeable #-}
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_HADDOCK not-home #-}

-- |
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/Data/Text/Lazy/Builder/RealFloat.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion src/Data/Text/Lazy/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{-# LANGUAGE BangPatterns, DeriveDataTypeable #-}
-- |
-- Module : Data.Text.Lazy.Internal
-- Copyright : (c) 2013 Bryan O'Sullivan
Expand Down
5 changes: 2 additions & 3 deletions tests/Tests/Properties/Substrings.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion tests/Tests/Properties/Transcoding.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down