Commit c409b6f3 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Remove redundant constraints from libraries, discovered by -fwarn-redundant-constraints

This patch affects libraries, and requires a submodule update.

Some other libraries, maintained by others, have redundant constraints,
namely:
           containers
           haskeline
           transformers
           binary

I have suppressed the redundant-constraint warnings by settings in
           validate-settings.mk
(in this commit)
parent 39337a6d
Subproject commit 4baaf0b6d1e7498f529e41eaa3a065cfa84b078c
Subproject commit e69fab76b5b15d7e7f413edb936faab30d05b8a0
......@@ -1064,7 +1064,7 @@ ratioConstr = mkConstr ratioDataType ":%" [] Infix
ratioDataType :: DataType
ratioDataType = mkDataType "GHC.Real.Ratio" [ratioConstr]
instance (Data a, Integral a) => Data (Ratio a) where
instance Data a => Data (Ratio a) where
gfoldl k z (a :% b) = z (:%) `k` a `k` b
toConstr _ = ratioConstr
gunfold k z c | constrIndex c == 1 = k (k (z (:%)))
......@@ -1303,7 +1303,7 @@ instance (Data a, Data b, Data c, Data d, Data e, Data f, Data g)
------------------------------------------------------------------------------
instance (Data a, Typeable a) => Data (Ptr a) where
instance Data a => Data (Ptr a) where
toConstr _ = error "Data.Data.toConstr(Ptr)"
gunfold _ _ = error "Data.Data.gunfold(Ptr)"
dataTypeOf _ = mkNoRepType "GHC.Ptr.Ptr"
......@@ -1311,7 +1311,7 @@ instance (Data a, Typeable a) => Data (Ptr a) where
------------------------------------------------------------------------------
instance (Data a, Typeable a) => Data (ForeignPtr a) where
instance Data a => Data (ForeignPtr a) where
toConstr _ = error "Data.Data.toConstr(ForeignPtr)"
gunfold _ _ = error "Data.Data.gunfold(ForeignPtr)"
dataTypeOf _ = mkNoRepType "GHC.ForeignPtr.ForeignPtr"
......@@ -1320,7 +1320,7 @@ instance (Data a, Typeable a) => Data (ForeignPtr a) where
------------------------------------------------------------------------------
-- The Data instance for Array preserves data abstraction at the cost of
-- inefficiency. We omit reflection services for the sake of data abstraction.
instance (Typeable a, Data a, Data b, Ix a) => Data (Array a b)
instance (Data a, Data b, Ix a) => Data (Array a b)
where
gfoldl f z a = z (listArray (bounds a)) `f` (elems a)
toConstr _ = error "Data.Data.toConstr(Array)"
......
......@@ -56,7 +56,7 @@ import Data.Monoid
import Data.Ord
import Data.Proxy
import GHC.Arr ( Array(..), Ix(..), elems, numElements,
import GHC.Arr ( Array(..), elems, numElements,
foldlElems, foldrElems,
foldlElems', foldrElems',
foldl1Elems, foldr1Elems)
......@@ -254,7 +254,7 @@ instance Foldable ((,) a) where
foldr f z (_, y) = f y z
instance Ix i => Foldable (Array i) where
instance Foldable (Array i) where
foldr = foldrElems
foldl = foldlElems
foldl' = foldlElems'
......
......@@ -450,7 +450,7 @@ unsafeArray :: Ix i => (i,i) -> [(Int, e)] -> Array i e
unsafeArray b ies = unsafeArray' b (rangeSize b) ies
{-# INLINE unsafeArray' #-}
unsafeArray' :: Ix i => (i,i) -> Int -> [(Int, e)] -> Array i e
unsafeArray' :: (i,i) -> Int -> [(Int, e)] -> Array i e
unsafeArray' (l,u) n@(I# n#) ies = runST (ST $ \s1# ->
case newArray# n# arrEleBottom s1# of
(# s2#, marr# #) ->
......@@ -465,7 +465,7 @@ fill marr# (I# i#, e) next
s2# -> next s2#
{-# INLINE done #-}
done :: Ix i => i -> i -> Int -> MutableArray# s e -> STRep s (Array i e)
done :: i -> i -> Int -> MutableArray# s e -> STRep s (Array i e)
-- See NB on 'fill'
-- Make sure it is strict in 'n'
done l u n@(I# _) marr#
......@@ -535,18 +535,18 @@ badSafeIndex i' n = error ("Error in array index; " ++ show i' ++
" not in range [0.." ++ show n ++ ")")
{-# INLINE unsafeAt #-}
unsafeAt :: Ix i => Array i e -> Int -> e
unsafeAt :: Array i e -> Int -> e
unsafeAt (Array _ _ _ arr#) (I# i#) =
case indexArray# arr# i# of (# e #) -> e
-- | The bounds with which an array was constructed.
{-# INLINE bounds #-}
bounds :: Ix i => Array i e -> (i,i)
bounds :: Array i e -> (i,i)
bounds (Array l u _ _) = (l,u)
-- | The number of elements in the array.
{-# INLINE numElements #-}
numElements :: Ix i => Array i e -> Int
numElements :: Array i e -> Int
numElements (Array _ _ n _) = n
-- | The list of indices of an array in ascending order.
......@@ -556,13 +556,13 @@ indices (Array l u _ _) = range (l,u)
-- | The list of elements of an array in index order.
{-# INLINE elems #-}
elems :: Ix i => Array i e -> [e]
elems :: Array i e -> [e]
elems arr@(Array _ _ n _) =
[unsafeAt arr i | i <- [0 .. n - 1]]
-- | A right fold over the elements
{-# INLINABLE foldrElems #-}
foldrElems :: Ix i => (a -> b -> b) -> b -> Array i a -> b
foldrElems :: (a -> b -> b) -> b -> Array i a -> b
foldrElems f b0 = \ arr@(Array _ _ n _) ->
let
go i | i == n = b0
......@@ -571,7 +571,7 @@ foldrElems f b0 = \ arr@(Array _ _ n _) ->
-- | A left fold over the elements
{-# INLINABLE foldlElems #-}
foldlElems :: Ix i => (b -> a -> b) -> b -> Array i a -> b
foldlElems :: (b -> a -> b) -> b -> Array i a -> b
foldlElems f b0 = \ arr@(Array _ _ n _) ->
let
go i | i == (-1) = b0
......@@ -580,7 +580,7 @@ foldlElems f b0 = \ arr@(Array _ _ n _) ->
-- | A strict right fold over the elements
{-# INLINABLE foldrElems' #-}
foldrElems' :: Ix i => (a -> b -> b) -> b -> Array i a -> b
foldrElems' :: (a -> b -> b) -> b -> Array i a -> b
foldrElems' f b0 = \ arr@(Array _ _ n _) ->
let
go i a | i == (-1) = a
......@@ -589,7 +589,7 @@ foldrElems' f b0 = \ arr@(Array _ _ n _) ->
-- | A strict left fold over the elements
{-# INLINABLE foldlElems' #-}
foldlElems' :: Ix i => (b -> a -> b) -> b -> Array i a -> b
foldlElems' :: (b -> a -> b) -> b -> Array i a -> b
foldlElems' f b0 = \ arr@(Array _ _ n _) ->
let
go i a | i == n = a
......@@ -598,7 +598,7 @@ foldlElems' f b0 = \ arr@(Array _ _ n _) ->
-- | A left fold over the elements with no starting value
{-# INLINABLE foldl1Elems #-}
foldl1Elems :: Ix i => (a -> a -> a) -> Array i a -> a
foldl1Elems :: (a -> a -> a) -> Array i a -> a
foldl1Elems f = \ arr@(Array _ _ n _) ->
let
go i | i == 0 = unsafeAt arr 0
......@@ -608,7 +608,7 @@ foldl1Elems f = \ arr@(Array _ _ n _) ->
-- | A right fold over the elements with no starting value
{-# INLINABLE foldr1Elems #-}
foldr1Elems :: Ix i => (a -> a -> a) -> Array i a -> a
foldr1Elems :: (a -> a -> a) -> Array i a -> a
foldr1Elems f = \ arr@(Array _ _ n _) ->
let
go i | i == n-1 = unsafeAt arr i
......@@ -653,7 +653,7 @@ unsafeAccumArray :: Ix i => (e -> a -> e) -> e -> (i,i) -> [(Int, a)] -> Array i
unsafeAccumArray f initial b ies = unsafeAccumArray' f initial b (rangeSize b) ies
{-# INLINE unsafeAccumArray' #-}
unsafeAccumArray' :: Ix i => (e -> a -> e) -> e -> (i,i) -> Int -> [(Int, a)] -> Array i e
unsafeAccumArray' :: (e -> a -> e) -> e -> (i,i) -> Int -> [(Int, a)] -> Array i e
unsafeAccumArray' f initial (l,u) n@(I# n#) ies = runST (ST $ \s1# ->
case newArray# n# initial s1# of { (# s2#, marr# #) ->
foldr (adjust f marr#) (done l u n marr#) ies s2# })
......@@ -684,7 +684,7 @@ arr@(Array l u n _) // ies =
unsafeReplace arr [(safeIndex (l,u) n i, e) | (i, e) <- ies]
{-# INLINE unsafeReplace #-}
unsafeReplace :: Ix i => Array i e -> [(Int, e)] -> Array i e
unsafeReplace :: Array i e -> [(Int, e)] -> Array i e
unsafeReplace arr ies = runST (do
STArray l u n marr# <- thawSTArray arr
ST (foldr (fill marr#) (done l u n marr#) ies))
......@@ -701,13 +701,13 @@ accum f arr@(Array l u n _) ies =
unsafeAccum f arr [(safeIndex (l,u) n i, e) | (i, e) <- ies]
{-# INLINE unsafeAccum #-}
unsafeAccum :: Ix i => (e -> a -> e) -> Array i e -> [(Int, a)] -> Array i e
unsafeAccum :: (e -> a -> e) -> Array i e -> [(Int, a)] -> Array i e
unsafeAccum f arr ies = runST (do
STArray l u n marr# <- thawSTArray arr
ST (foldr (adjust f marr#) (done l u n marr#) ies))
{-# INLINE [1] amap #-}
amap :: Ix i => (a -> b) -> Array i a -> Array i b
amap :: (a -> b) -> Array i a -> Array i b
amap f arr@(Array l u n@(I# n#) _) = runST (ST $ \s1# ->
case newArray# n# arrEleBottom s1# of
(# s2#, marr# #) ->
......@@ -786,7 +786,7 @@ cmpIntArray arr1@(Array l1 u1 n1 _) arr2@(Array l2 u2 n2 _) =
----------------------------------------------------------------------
-- Array instances
instance Ix i => Functor (Array i) where
instance Functor (Array i) where
fmap = amap
instance (Ix i, Eq e) => Eq (Array i e) where
......@@ -845,7 +845,7 @@ readSTArray marr@(STArray l u n _) i =
unsafeReadSTArray marr (safeIndex (l,u) n i)
{-# INLINE unsafeReadSTArray #-}
unsafeReadSTArray :: Ix i => STArray s i e -> Int -> ST s e
unsafeReadSTArray :: STArray s i e -> Int -> ST s e
unsafeReadSTArray (STArray _ _ _ marr#) (I# i#)
= ST $ \s1# -> readArray# marr# i# s1#
......@@ -855,7 +855,7 @@ writeSTArray marr@(STArray l u n _) i e =
unsafeWriteSTArray marr (safeIndex (l,u) n i) e
{-# INLINE unsafeWriteSTArray #-}
unsafeWriteSTArray :: Ix i => STArray s i e -> Int -> e -> ST s ()
unsafeWriteSTArray :: STArray s i e -> Int -> e -> ST s ()
unsafeWriteSTArray (STArray _ _ _ marr#) (I# i#) e = ST $ \s1# ->
case writeArray# marr# i# e s1# of
s2# -> (# s2#, () #)
......@@ -863,7 +863,7 @@ unsafeWriteSTArray (STArray _ _ _ marr#) (I# i#) e = ST $ \s1# ->
----------------------------------------------------------------------
-- Moving between mutable and immutable
freezeSTArray :: Ix i => STArray s i e -> ST s (Array i e)
freezeSTArray :: STArray s i e -> ST s (Array i e)
freezeSTArray (STArray l u n@(I# n#) marr#) = ST $ \s1# ->
case newArray# n# arrEleBottom s1# of { (# s2#, marr'# #) ->
let copy i# s3# | isTrue# (i# ==# n#) = s3#
......@@ -876,12 +876,12 @@ freezeSTArray (STArray l u n@(I# n#) marr#) = ST $ \s1# ->
(# s4#, Array l u n arr# #) }}}
{-# INLINE unsafeFreezeSTArray #-}
unsafeFreezeSTArray :: Ix i => STArray s i e -> ST s (Array i e)
unsafeFreezeSTArray :: STArray s i e -> ST s (Array i e)
unsafeFreezeSTArray (STArray l u n marr#) = ST $ \s1# ->
case unsafeFreezeArray# marr# s1# of { (# s2#, arr# #) ->
(# s2#, Array l u n arr# #) }
thawSTArray :: Ix i => Array i e -> ST s (STArray s i e)
thawSTArray :: Array i e -> ST s (STArray s i e)
thawSTArray (Array l u n@(I# n#) arr#) = ST $ \s1# ->
case newArray# n# arrEleBottom s1# of { (# s2#, marr# #) ->
let copy i# s3# | isTrue# (i# ==# n#) = s3#
......@@ -893,7 +893,7 @@ thawSTArray (Array l u n@(I# n#) arr#) = ST $ \s1# ->
(# s3#, STArray l u n marr# #) }}
{-# INLINE unsafeThawSTArray #-}
unsafeThawSTArray :: Ix i => Array i e -> ST s (STArray s i e)
unsafeThawSTArray :: Array i e -> ST s (STArray s i e)
unsafeThawSTArray (Array l u n arr#) = ST $ \s1# ->
case unsafeThawArray# arr# s1# of { (# s2#, marr# #) ->
(# s2#, STArray l u n marr# #) }
......@@ -132,7 +132,7 @@ unsafeWrite' (AC es _ cap) ix a = do
withForeignPtr es $ \p ->
pokeElemOff p ix a
unsafeLoad :: Storable a => Array a -> (Ptr a -> Int -> IO Int) -> IO Int
unsafeLoad :: Array a -> (Ptr a -> Int -> IO Int) -> IO Int
unsafeLoad (Array ref) load = do
AC es _ cap <- readIORef ref
len' <- withForeignPtr es $ \p -> load p cap
......@@ -170,7 +170,7 @@ snoc (Array ref) e = do
unsafeWrite' ac' len e
writeIORef ref (AC es len' cap)
clear :: Storable a => Array a -> IO ()
clear :: Array a -> IO ()
clear (Array ref) = do
atomicModifyIORef' ref $ \(AC es _ cap) ->
(AC es 0 cap, ())
......
......@@ -54,12 +54,12 @@ newIOArray :: Ix i => (i,i) -> e -> IO (IOArray i e)
newIOArray lu initial = stToIO $ do {marr <- newSTArray lu initial; return (IOArray marr)}
-- | Read a value from an 'IOArray'
unsafeReadIOArray :: Ix i => IOArray i e -> Int -> IO e
unsafeReadIOArray :: IOArray i e -> Int -> IO e
{-# INLINE unsafeReadIOArray #-}
unsafeReadIOArray (IOArray marr) i = stToIO (unsafeReadSTArray marr i)
-- | Write a new value into an 'IOArray'
unsafeWriteIOArray :: Ix i => IOArray i e -> Int -> e -> IO ()
unsafeWriteIOArray :: IOArray i e -> Int -> e -> IO ()
{-# INLINE unsafeWriteIOArray #-}
unsafeWriteIOArray (IOArray marr) i e = stToIO (unsafeWriteSTArray marr i e)
......
......@@ -103,12 +103,12 @@ notANumber = 0 :% 0
-- | Extract the numerator of the ratio in reduced form:
-- the numerator and denominator have no common factor and the denominator
-- is positive.
numerator :: (Integral a) => Ratio a -> a
numerator :: Ratio a -> a
-- | Extract the denominator of the ratio in reduced form:
-- the numerator and denominator have no common factor and the denominator
-- is positive.
denominator :: (Integral a) => Ratio a -> a
denominator :: Ratio a -> a
-- | 'reduce' is a subsidiary function used only in this module.
......@@ -410,7 +410,7 @@ instance (Integral a) => RealFrac (Ratio a) where
properFraction (x:%y) = (fromInteger (toInteger q), r:%y)
where (q,r) = quotRem x y
instance (Integral a, Show a) => Show (Ratio a) where
instance (Show a) => Show (Ratio a) where
{-# SPECIALIZE instance Show Rational #-}
showsPrec p (x:%y) = showParen (p > ratioPrec) $
showsPrec ratioPrec1 x .
......
......@@ -461,7 +461,7 @@ intModifierMap = [
("ll", toInteger (minBound :: Int64)),
("L", toInteger (minBound :: Int64)) ]
parseIntFormat :: Integral a => a -> String -> FormatParse
parseIntFormat :: a -> String -> FormatParse
parseIntFormat _ s =
case foldr matchPrefix Nothing intModifierMap of
Just m -> m
......
Subproject commit a79bee5f5da25353b88759cf5ed8d0df2b59946c
Subproject commit de1bc894de1ffdd34e6eb8be4fb9e057198060c6
Subproject commit d39ddd928e0d691ee571768a613fd10f6f951a40
Subproject commit b38e92f67cabfa0d0ed12ac93c2d431f2391de70
Subproject commit 5b86f00553688195ea3496d9b7052ec1a9a9c2fe
Subproject commit e4e4228ba94178cf31b97fe81b94bff3de6fce03
......@@ -104,6 +104,7 @@ utils/haddock_dist_EXTRA_HC_OPTS += -fno-warn-deprecations
# containers uses bitSize at the moment
libraries/containers_dist-install_EXTRA_HC_OPTS += -fno-warn-deprecations
libraries/containers_dist-install_EXTRA_HC_OPTS += -fno-warn-redundant-constraints
# On Windows, there are also some unused import warnings
ifeq "$(HostOS_CPP)" "mingw32"
......@@ -113,6 +114,7 @@ endif
# haskeline has warnings about deprecated use of block/unblock
libraries/haskeline_dist-install_EXTRA_HC_OPTS += -fno-warn-deprecations
libraries/haskeline_dist-install_EXTRA_HC_OPTS += -fno-warn-unused-imports
libraries/haskeline_dist-install_EXTRA_HC_OPTS += -fno-warn-redundant-constraints
# binary upstream has some warnings, so don't use -Werror for it
libraries/binary_dist-boot_EXTRA_HC_OPTS += -Wwarn
......@@ -143,6 +145,7 @@ libraries/dph/dph-lifted-common-install_EXTRA_HC_OPTS += -Wwarn
# transformers has unused function parameters warnings
libraries/transformers_dist-boot_EXTRA_HC_OPTS += -fno-warn-unused-matches -fno-warn-unused-imports
libraries/transformers_dist-install_EXTRA_HC_OPTS += -fno-warn-unused-matches -fno-warn-unused-imports
libraries/transformers_dist-install_EXTRA_HC_OPTS += -fno-warn-redundant-constraints
# Turn of trustworthy-safe warning
libraries/base_dist-install_EXTRA_HC_OPTS += -fno-warn-trustworthy-safe
......
Markdown is supported
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