diff options
28 files changed, 95 insertions, 27 deletions
diff --git a/compiler/deSugar/MatchLit.lhs b/compiler/deSugar/MatchLit.lhs index f404997c9f..5a247177a3 100644 --- a/compiler/deSugar/MatchLit.lhs +++ b/compiler/deSugar/MatchLit.lhs @@ -46,7 +46,9 @@ import FastString import Control.Monad import Data.Int +#if __GLASGOW_HASKELL__ < 709 import Data.Traversable (traverse) +#endif import Data.Word \end{code} diff --git a/compiler/ghci/RtClosureInspect.hs b/compiler/ghci/RtClosureInspect.hs index dde813d31d..0b69492b0a 100644 --- a/compiler/ghci/RtClosureInspect.hs +++ b/compiler/ghci/RtClosureInspect.hs @@ -65,7 +65,9 @@ import Data.Array.Base import Data.Ix import Data.List import qualified Data.Sequence as Seq +#if __GLASGOW_HASKELL__ < 709 import Data.Monoid (mappend) +#endif import Data.Sequence (viewl, ViewL(..)) import Foreign.Safe import System.IO.Unsafe diff --git a/compiler/hsSyn/HsBinds.lhs b/compiler/hsSyn/HsBinds.lhs index 5ebada6e9c..e6d0c0ecd5 100644 --- a/compiler/hsSyn/HsBinds.lhs +++ b/compiler/hsSyn/HsBinds.lhs @@ -41,10 +41,10 @@ import BooleanFormula (BooleanFormula) import Data.Data hiding ( Fixity ) import Data.List import Data.Ord +#if __GLASGOW_HASKELL__ < 709 import Data.Foldable ( Foldable(..) ) import Data.Traversable ( Traversable(..) ) import Data.Monoid ( mappend ) -#if __GLASGOW_HASKELL__ < 709 import Control.Applicative hiding (empty) #else import Control.Applicative ((<$>)) diff --git a/compiler/iface/TcIface.lhs b/compiler/iface/TcIface.lhs index 37b65b01af..293e8c9c4c 100644 --- a/compiler/iface/TcIface.lhs +++ b/compiler/iface/TcIface.lhs @@ -72,7 +72,9 @@ import FastString import Control.Monad import qualified Data.Map as Map +#if __GLASGOW_HASKELL__ < 709 import Data.Traversable ( traverse ) +#endif \end{code} This module takes diff --git a/compiler/main/Packages.lhs b/compiler/main/Packages.lhs index a6a61e9534..93370d47b3 100644 --- a/compiler/main/Packages.lhs +++ b/compiler/main/Packages.lhs @@ -73,7 +73,9 @@ import qualified System.FilePath.Posix as FilePath.Posix import Control.Monad import Data.List as List import Data.Map (Map) +#if __GLASGOW_HASKELL__ < 709 import Data.Monoid hiding ((<>)) +#endif import qualified Data.Map as Map import qualified FiniteMap as Map import qualified Data.Set as Set diff --git a/compiler/rename/RnBinds.lhs b/compiler/rename/RnBinds.lhs index dfbde13ded..f76090f3d9 100644 --- a/compiler/rename/RnBinds.lhs +++ b/compiler/rename/RnBinds.lhs @@ -9,6 +9,7 @@ type-synonym declarations; those cannot be done at this stage because they may be affected by renaming (which isn't fully worked out yet). \begin{code} +{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-tabs #-} -- The above warning supression flag is a temporary kludge. -- While working on this module you are encouraged to remove it and @@ -55,7 +56,9 @@ import FastString import Data.List ( partition, sort ) import Maybes ( orElse ) import Control.Monad +#if __GLASGOW_HASKELL__ < 709 import Data.Traversable ( traverse ) +#endif \end{code} -- ToDo: Put the annotations into the monad, so that they arrive in the proper diff --git a/compiler/rename/RnSource.lhs b/compiler/rename/RnSource.lhs index 4af8be32fd..6aa666642f 100644 --- a/compiler/rename/RnSource.lhs +++ b/compiler/rename/RnSource.lhs @@ -48,7 +48,9 @@ import Util ( mapSnd ) import Control.Monad import Data.List( partition, sortBy ) +#if __GLASGOW_HASKELL__ < 709 import Data.Traversable (traverse) +#endif import Maybes( orElse, mapMaybe ) \end{code} diff --git a/compiler/typecheck/TcEvidence.lhs b/compiler/typecheck/TcEvidence.lhs index 8b64d2408b..468f9c3956 100644 --- a/compiler/typecheck/TcEvidence.lhs +++ b/compiler/typecheck/TcEvidence.lhs @@ -50,7 +50,9 @@ import Util import Bag import Pair import Control.Applicative +#if __GLASGOW_HASKELL__ < 709 import Data.Traversable (traverse, sequenceA) +#endif import qualified Data.Data as Data import Outputable import FastString diff --git a/compiler/typecheck/TcHsSyn.lhs b/compiler/typecheck/TcHsSyn.lhs index f4d5cf262c..b19bfbbdc1 100644 --- a/compiler/typecheck/TcHsSyn.lhs +++ b/compiler/typecheck/TcHsSyn.lhs @@ -58,7 +58,9 @@ import Bag import FastString import Outputable import Util +#if __GLASGOW_HASKELL__ < 709 import Data.Traversable ( traverse ) +#endif \end{code} %************************************************************************ diff --git a/compiler/typecheck/TcPatSyn.lhs b/compiler/typecheck/TcPatSyn.lhs index 6ae3ba0153..9b2b5110f4 100644 --- a/compiler/typecheck/TcPatSyn.lhs +++ b/compiler/typecheck/TcPatSyn.lhs @@ -30,7 +30,9 @@ import BasicTypes import TcSimplify import TcType import VarSet +#if __GLASGOW_HASKELL__ < 709 import Data.Monoid +#endif import Bag import TcEvidence import BuildTyCl diff --git a/compiler/types/Coercion.lhs b/compiler/types/Coercion.lhs index fc6c8a7669..36eb711bdc 100644 --- a/compiler/types/Coercion.lhs +++ b/compiler/types/Coercion.lhs @@ -102,7 +102,9 @@ import Pair import SrcLoc import PrelNames ( funTyConKey, eqPrimTyConKey, eqReprPrimTyConKey ) import Control.Applicative +#if __GLASGOW_HASKELL__ < 709 import Data.Traversable (traverse, sequenceA) +#endif import FastString import ListSetOps diff --git a/compiler/utils/Pair.lhs b/compiler/utils/Pair.lhs index ca7c2a7f8e..529ba669ea 100644 --- a/compiler/utils/Pair.lhs +++ b/compiler/utils/Pair.lhs @@ -10,10 +10,12 @@ module Pair ( Pair(..), unPair, toPair, swap ) where #include "HsVersions.h" import Outputable -import Data.Monoid import Control.Applicative +#if __GLASGOW_HASKELL__ < 709 import Data.Foldable +import Data.Monoid import Data.Traversable +#endif data Pair a = Pair { pFst :: a, pSnd :: a } -- Note that Pair is a *unary* type constructor @@ -46,4 +48,4 @@ toPair (x,y) = Pair x y swap :: Pair a -> Pair a swap (Pair x y) = Pair y x -\end{code}
\ No newline at end of file +\end{code} diff --git a/compiler/utils/UniqFM.lhs b/compiler/utils/UniqFM.lhs index d8e08f599a..c941ce8884 100644 --- a/compiler/utils/UniqFM.lhs +++ b/compiler/utils/UniqFM.lhs @@ -20,7 +20,10 @@ and ``addToUFM\_C'' and ``Data.IntMap.insertWith'' differ in the order of arguments of combining function. \begin{code} -{-# LANGUAGE DeriveTraversable, DeriveDataTypeable, GeneralizedNewtypeDeriving #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# OPTIONS_GHC -Wall #-} module UniqFM ( @@ -76,7 +79,9 @@ import qualified Data.Foldable as Foldable import qualified Data.Traversable as Traversable import Data.Typeable import Data.Data +#if __GLASGOW_HASKELL__ < 709 import Data.Monoid +#endif \end{code} %************************************************************************ diff --git a/libraries/base/Prelude.hs b/libraries/base/Prelude.hs index 854456a3db..fd439b5232 100644 --- a/libraries/base/Prelude.hs +++ b/libraries/base/Prelude.hs @@ -66,14 +66,32 @@ module Prelude ( subtract, even, odd, gcd, lcm, (^), (^^), fromIntegral, realToFrac, + -- ** Monoids + Monoid(mempty, mappend, mconcat), + -- ** Monads and functors Functor(fmap), Applicative(pure, (<*>), (*>), (<*)), Monad((>>=), (>>), return, fail), - mapM, mapM_, sequence, sequence_, (=<<), - - -- ** Traversals and Foldables - Foldable, Traversable, + mapM_, sequence_, (=<<), + + -- ** Folds and traversals + Foldable(elem, -- :: (Foldable t, Eq a) => a -> t a -> Bool + -- fold, -- :: Monoid m => t m -> m + foldMap, -- :: Monoid m => (a -> m) -> t a -> m + foldr, -- :: (a -> b -> b) -> b -> t a -> b + -- foldr', -- :: (a -> b -> b) -> b -> t a -> b + foldl, -- :: (b -> a -> b) -> b -> t a -> b + -- foldl', -- :: (b -> a -> b) -> b -> t a -> b + foldr1, -- :: (a -> a -> a) -> t a -> a + foldl1, -- :: (a -> a -> a) -> t a -> a + maximum, -- :: (Foldable t, Ord a) => t a -> a + minimum, -- :: (Foldable t, Ord a) => t a -> a + product, -- :: (Foldable t, Num a) => t a -> a + sum), -- :: Num a => t a -> a + -- toList) -- :: Foldable t => t a -> [a] + + Traversable(traverse, sequenceA, mapM, sequence), -- ** Miscellaneous functions id, const, (.), flip, ($), until, @@ -84,13 +102,9 @@ module Prelude ( map, (++), filter, head, last, tail, init, null, length, (!!), reverse, - -- ** Reducing lists (folds) - foldl, foldl1, foldr, foldr1, -- *** Special folds and, or, any, all, - sum, product, concat, concatMap, - maximum, minimum, -- ** Building lists -- *** Scans scanl, scanl1, scanr, scanr1, @@ -99,7 +113,7 @@ module Prelude ( -- ** Sublists take, drop, splitAt, takeWhile, dropWhile, span, break, -- ** Searching lists - elem, notElem, lookup, + notElem, lookup, -- ** Zipping and unzipping lists zip, zip3, zipWith, zipWith3, unzip, unzip3, -- ** Functions on strings @@ -143,9 +157,9 @@ import System.IO import System.IO.Error import Data.List import Data.Either -import Data.Foldable ( Foldable ) +import Data.Foldable ( Foldable(..) ) import Data.Maybe -import Data.Traversable ( Traversable ) +import Data.Traversable ( Traversable(..) ) import Data.Tuple import GHC.Base hiding ( foldr, mapM, sequence ) diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index 0d9589847a..1afcb0edc5 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -29,6 +29,13 @@ * Add `Data.List.uncons` list destructor (#9550) + * Export `Monoid(..)` from `Prelude` + + * Export `Foldable(..)` from `Prelude` + (hiding `fold`, `foldl'`, `foldr'`, and `toList`) + + * Export `Traversable(..)` from `Prelude` + * Set fixity for `Data.Foldable.{elem,notElem}` to match the conventional one set for `Data.List.{elem,notElem}` (#9610) diff --git a/mk/validate-settings.mk b/mk/validate-settings.mk index fad83c9c4b..734e28de7b 100644 --- a/mk/validate-settings.mk +++ b/mk/validate-settings.mk @@ -132,9 +132,15 @@ libraries/binary_dist-install_EXTRA_HC_OPTS += -Wwarn # temporarily turn off -Werror for mtl libraries/mtl_dist-install_EXTRA_HC_OPTS += -Wwarn +# temporarily turn off unused-imports warnings for pretty +libraries/pretty_dist-install_EXTRA_HC_OPTS += -fno-warn-unused-imports + # primitive has a warning about deprecated use of GHC.IOBase libraries/primitive_dist-install_EXTRA_HC_OPTS += -Wwarn +# temporarily turn off unused-imports warnings for terminfo +libraries/terminfo_dist-install_EXTRA_HC_OPTS += -fno-warn-unused-imports + # temporarily turn off -Werror for transformers libraries/transformers_dist-boot_EXTRA_HC_OPTS += -Wwarn libraries/transformers_dist-install_EXTRA_HC_OPTS += -Wwarn @@ -142,6 +148,9 @@ libraries/transformers_dist-install_EXTRA_HC_OPTS += -Wwarn # vector has some unused match warnings libraries/vector_dist-install_EXTRA_HC_OPTS += -Wwarn +# temporarily turn off unused-imports warnings for xhtml +libraries/xhtml_dist-install_EXTRA_HC_OPTS += -fno-warn-unused-imports + libraries/dph/dph-base_dist-install_EXTRA_HC_OPTS += -Wwarn libraries/dph/dph-prim-interface_dist-install_EXTRA_HC_OPTS += -Wwarn libraries/dph/dph-prim-seq_dist-install_EXTRA_HC_OPTS += -Wwarn diff --git a/testsuite/tests/ghci.debugger/mdo.hs b/testsuite/tests/ghci.debugger/mdo.hs index 761c056658..bc5d8dd9ea 100644 --- a/testsuite/tests/ghci.debugger/mdo.hs +++ b/testsuite/tests/ghci.debugger/mdo.hs @@ -1,5 +1,6 @@ import Control.Monad.Fix import Data.IORef +import Prelude hiding (traverse) data N a = N (IORef Bool, N a, a, N a) @@ -34,4 +35,4 @@ l2dll' :: N a -> [a] -> IO (N a, N a) l2dll' p [] = return (p, p) l2dll' p (x:xs) = mdo c <- newNode p x f (f, l) <- l2dll' c xs - return (c, l)
\ No newline at end of file + return (c, l) diff --git a/testsuite/tests/ghci.debugger/scripts/break018.stdout b/testsuite/tests/ghci.debugger/scripts/break018.stdout index a495e7903a..a12e119a42 100644 --- a/testsuite/tests/ghci.debugger/scripts/break018.stdout +++ b/testsuite/tests/ghci.debugger/scripts/break018.stdout @@ -1,13 +1,13 @@ -Stopped at ../mdo.hs:(29,1)-(31,27) +Stopped at ../mdo.hs:(30,1)-(32,27) _result :: IO (N a) = _ -Stopped at ../mdo.hs:(29,16)-(31,27) +Stopped at ../mdo.hs:(30,16)-(32,27) _result :: IO (N Char) = _ x :: Char = 'h' xs :: [Char] = _ -Stopped at ../mdo.hs:29:30-42 +Stopped at ../mdo.hs:30:30-42 _result :: IO (N Char) = _ f :: N Char = _ l :: N Char = _ x :: Char = 'h' -Stopped at ../mdo.hs:(7,1)-(8,42) +Stopped at ../mdo.hs:(8,1)-(9,42) _result :: IO (N a) = _ diff --git a/testsuite/tests/ghci.debugger/scripts/dynbrk004.stdout b/testsuite/tests/ghci.debugger/scripts/dynbrk004.stdout index ed7fb990a4..dfdfc45a6b 100644 --- a/testsuite/tests/ghci.debugger/scripts/dynbrk004.stdout +++ b/testsuite/tests/ghci.debugger/scripts/dynbrk004.stdout @@ -1,4 +1,4 @@ Breakpoint 0 activated at ../mdo.hs:13:16-30 Breakpoint 1 activated at ../mdo.hs:12:16-30 Breakpoint 2 activated at ../mdo.hs:11:16-30 -Breakpoint 3 activated at ../mdo.hs:14:10-18 +Breakpoint 3 activated at ../mdo.hs:14:16-30 diff --git a/testsuite/tests/ghci/scripts/T4175.stdout b/testsuite/tests/ghci/scripts/T4175.stdout index e439528965..7c063a6481 100644 --- a/testsuite/tests/ghci/scripts/T4175.stdout +++ b/testsuite/tests/ghci/scripts/T4175.stdout @@ -25,6 +25,7 @@ instance Eq () -- Defined in ‘GHC.Classes’ instance Ord () -- Defined in ‘GHC.Classes’ instance Read () -- Defined in ‘GHC.Read’ instance Show () -- Defined in ‘GHC.Show’ +instance Monoid () -- Defined in ‘GHC.Base’ type instance D () () = Bool -- Defined at T4175.hs:22:5 type instance D Int () = String -- Defined at T4175.hs:19:5 data instance B () = MkB -- Defined at T4175.hs:13:15 @@ -38,6 +39,7 @@ instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’ instance Applicative Maybe -- Defined in ‘GHC.Base’ instance Foldable Maybe -- Defined in ‘Data.Foldable’ instance Traversable Maybe -- Defined in ‘Data.Traversable’ +instance Monoid a => Monoid (Maybe a) -- Defined in ‘GHC.Base’ type instance A (Maybe a) a = a -- Defined at T4175.hs:9:1 data Int = I# Int# -- Defined in ‘GHC.Types’ instance C Int -- Defined at T4175.hs:18:10 diff --git a/testsuite/tests/ghci/scripts/T7627.stdout b/testsuite/tests/ghci/scripts/T7627.stdout index 451c7051df..27135662d4 100644 --- a/testsuite/tests/ghci/scripts/T7627.stdout +++ b/testsuite/tests/ghci/scripts/T7627.stdout @@ -5,6 +5,7 @@ instance Eq () -- Defined in ‘GHC.Classes’ instance Ord () -- Defined in ‘GHC.Classes’ instance Read () -- Defined in ‘GHC.Read’ instance Show () -- Defined in ‘GHC.Show’ +instance Monoid () -- Defined in ‘GHC.Base’ data (##) = (##) -- Defined in ‘GHC.Prim’ () :: () (##) :: (# #) @@ -18,10 +19,11 @@ instance Functor ((,) a) -- Defined in ‘GHC.Base’ instance (Ord a, Ord b) => Ord (a, b) -- Defined in ‘GHC.Classes’ instance (Read a, Read b) => Read (a, b) -- Defined in ‘GHC.Read’ instance (Show a, Show b) => Show (a, b) -- Defined in ‘GHC.Show’ -instance GHC.Base.Monoid a => Applicative ((,) a) - -- Defined in ‘GHC.Base’ +instance Monoid a => Applicative ((,) a) -- Defined in ‘GHC.Base’ instance Foldable ((,) a) -- Defined in ‘Data.Foldable’ instance Traversable ((,) a) -- Defined in ‘Data.Traversable’ +instance (Monoid a, Monoid b) => Monoid (a, b) + -- Defined in ‘GHC.Base’ data (#,#) (a :: OpenKind) (b :: OpenKind) = (#,#) a b -- Defined in ‘GHC.Prim’ (,) :: a -> b -> (a, b) diff --git a/testsuite/tests/ghci/scripts/ghci011.stdout b/testsuite/tests/ghci/scripts/ghci011.stdout index 0563b83e66..a608f079b5 100644 --- a/testsuite/tests/ghci/scripts/ghci011.stdout +++ b/testsuite/tests/ghci/scripts/ghci011.stdout @@ -8,6 +8,7 @@ instance Show a => Show [a] -- Defined in ‘GHC.Show’ instance Applicative [] -- Defined in ‘GHC.Base’ instance Foldable [] -- Defined in ‘Data.Foldable’ instance Traversable [] -- Defined in ‘Data.Traversable’ +instance Monoid [a] -- Defined in ‘GHC.Base’ data () = () -- Defined in ‘GHC.Tuple’ instance Bounded () -- Defined in ‘GHC.Enum’ instance Enum () -- Defined in ‘GHC.Enum’ @@ -15,6 +16,7 @@ instance Eq () -- Defined in ‘GHC.Classes’ instance Ord () -- Defined in ‘GHC.Classes’ instance Read () -- Defined in ‘GHC.Read’ instance Show () -- Defined in ‘GHC.Show’ +instance Monoid () -- Defined in ‘GHC.Base’ data (,) a b = (,) a b -- Defined in ‘GHC.Tuple’ instance (Bounded a, Bounded b) => Bounded (a, b) -- Defined in ‘GHC.Enum’ @@ -23,7 +25,8 @@ instance Functor ((,) a) -- Defined in ‘GHC.Base’ instance (Ord a, Ord b) => Ord (a, b) -- Defined in ‘GHC.Classes’ instance (Read a, Read b) => Read (a, b) -- Defined in ‘GHC.Read’ instance (Show a, Show b) => Show (a, b) -- Defined in ‘GHC.Show’ -instance GHC.Base.Monoid a => Applicative ((,) a) - -- Defined in ‘GHC.Base’ +instance Monoid a => Applicative ((,) a) -- Defined in ‘GHC.Base’ instance Foldable ((,) a) -- Defined in ‘Data.Foldable’ instance Traversable ((,) a) -- Defined in ‘Data.Traversable’ +instance (Monoid a, Monoid b) => Monoid (a, b) + -- Defined in ‘GHC.Base’ diff --git a/testsuite/tests/ghci/scripts/ghci020.stdout b/testsuite/tests/ghci/scripts/ghci020.stdout index bd3a045871..749a244f1f 100644 --- a/testsuite/tests/ghci/scripts/ghci020.stdout +++ b/testsuite/tests/ghci/scripts/ghci020.stdout @@ -2,3 +2,4 @@ data (->) a b -- Defined in ‘GHC.Prim’ instance Monad ((->) r) -- Defined in ‘GHC.Base’ instance Functor ((->) r) -- Defined in ‘GHC.Base’ instance Applicative ((->) a) -- Defined in ‘GHC.Base’ +instance Monoid b => Monoid (a -> b) -- Defined in ‘GHC.Base’ diff --git a/testsuite/tests/mdo/should_run/mdorun002.hs b/testsuite/tests/mdo/should_run/mdorun002.hs index 191e40039d..0a09451324 100644 --- a/testsuite/tests/mdo/should_run/mdorun002.hs +++ b/testsuite/tests/mdo/should_run/mdorun002.hs @@ -5,6 +5,7 @@ module Main(main) where import Control.Monad.Fix import Control.Monad.ST import Data.STRef +import Prelude hiding (traverse) newtype Node s a = N (STRef s Bool, Node s a, a, Node s a) diff --git a/testsuite/tests/quasiquotation/T7918.hs b/testsuite/tests/quasiquotation/T7918.hs index 7126cb166e..d549671b31 100644 --- a/testsuite/tests/quasiquotation/T7918.hs +++ b/testsuite/tests/quasiquotation/T7918.hs @@ -15,6 +15,7 @@ import Control.Monad import Control.Monad.Trans.State import Data.List import Data.Ord +import Prelude hiding (traverse) type Traverse a = State (SrcSpan, [(Name, SrcSpan)]) a diff --git a/testsuite/tests/typecheck/should_compile/DfltProb1.hs b/testsuite/tests/typecheck/should_compile/DfltProb1.hs index 822a5caac6..397e41e96d 100644 --- a/testsuite/tests/typecheck/should_compile/DfltProb1.hs +++ b/testsuite/tests/typecheck/should_compile/DfltProb1.hs @@ -2,6 +2,7 @@ module DfltProb1 where import Control.Monad.ST +import Prelude hiding (traverse) traverse :: a -> ST s [a] traverse = undefined diff --git a/utils/hpc/HpcMarkup.hs b/utils/hpc/HpcMarkup.hs index ebec912352..8fd9e4226c 100644 --- a/utils/hpc/HpcMarkup.hs +++ b/utils/hpc/HpcMarkup.hs @@ -17,7 +17,6 @@ import System.IO (localeEncoding) import Data.List import Data.Maybe(fromJust) import Data.Array -import Data.Monoid import Control.Monad import qualified Data.Set as Set diff --git a/utils/runghc/runghc.hs b/utils/runghc/runghc.hs index 47a6bc57d5..e94c5503c0 100644 --- a/utils/runghc/runghc.hs +++ b/utils/runghc/runghc.hs @@ -19,7 +19,6 @@ module Main (main) where import Control.Exception -import Data.Monoid import System.Directory import System.Environment import System.Exit |