diff options
Diffstat (limited to 'libraries/base')
50 files changed, 626 insertions, 321 deletions
diff --git a/libraries/base/.gitignore b/libraries/base/.gitignore index 69a9c5124b..3581b447ac 100644 --- a/libraries/base/.gitignore +++ b/libraries/base/.gitignore @@ -1,14 +1,6 @@ *.o *.aux *.hi -*.comp.stderr -*.comp.stdout -*.interp.stderr -*.interp.stdout -*.run.stderr -*.run.stdout -*.eventlog -*.genscript # Backup files *~ @@ -26,242 +18,3 @@ /include/HsBaseConfig.h /include/HsBaseConfig.h.in -tests/.hpc/ -tests/4006 -tests/CPUTime001 -tests/Concurrent/.hpc/ -tests/Concurrent/4876 -tests/Concurrent/ThreadDelay001 -tests/IO/.hpc/ -tests/IO/2122 -tests/IO/2122-test -tests/IO/3307 -tests/IO/4808 -tests/IO/4808.test -tests/IO/4855 -tests/IO/4895 -tests/IO/IOError001 -tests/IO/IOError002 -tests/IO/T4144 -tests/IO/chinese-file-* -tests/IO/chinese-name -tests/IO/concio002 -tests/IO/countReaders001 -tests/IO/countReaders001.txt -tests/IO/decodingerror001 -tests/IO/decodingerror002 -tests/IO/encoding001 -tests/IO/encoding001.utf16 -tests/IO/encoding001.utf16.utf16be -tests/IO/encoding001.utf16.utf16le -tests/IO/encoding001.utf16.utf32 -tests/IO/encoding001.utf16.utf32be -tests/IO/encoding001.utf16.utf32le -tests/IO/encoding001.utf16.utf8 -tests/IO/encoding001.utf16.utf8_bom -tests/IO/encoding001.utf16be -tests/IO/encoding001.utf16be.utf16 -tests/IO/encoding001.utf16be.utf16le -tests/IO/encoding001.utf16be.utf32 -tests/IO/encoding001.utf16be.utf32be -tests/IO/encoding001.utf16be.utf32le -tests/IO/encoding001.utf16be.utf8 -tests/IO/encoding001.utf16be.utf8_bom -tests/IO/encoding001.utf16le -tests/IO/encoding001.utf16le.utf16 -tests/IO/encoding001.utf16le.utf16be -tests/IO/encoding001.utf16le.utf32 -tests/IO/encoding001.utf16le.utf32be -tests/IO/encoding001.utf16le.utf32le -tests/IO/encoding001.utf16le.utf8 -tests/IO/encoding001.utf16le.utf8_bom -tests/IO/encoding001.utf32 -tests/IO/encoding001.utf32.utf16 -tests/IO/encoding001.utf32.utf16be -tests/IO/encoding001.utf32.utf16le -tests/IO/encoding001.utf32.utf32be -tests/IO/encoding001.utf32.utf32le -tests/IO/encoding001.utf32.utf8 -tests/IO/encoding001.utf32.utf8_bom -tests/IO/encoding001.utf32be -tests/IO/encoding001.utf32be.utf16 -tests/IO/encoding001.utf32be.utf16be -tests/IO/encoding001.utf32be.utf16le -tests/IO/encoding001.utf32be.utf32 -tests/IO/encoding001.utf32be.utf32le -tests/IO/encoding001.utf32be.utf8 -tests/IO/encoding001.utf32be.utf8_bom -tests/IO/encoding001.utf32le -tests/IO/encoding001.utf32le.utf16 -tests/IO/encoding001.utf32le.utf16be -tests/IO/encoding001.utf32le.utf16le -tests/IO/encoding001.utf32le.utf32 -tests/IO/encoding001.utf32le.utf32be -tests/IO/encoding001.utf32le.utf8 -tests/IO/encoding001.utf32le.utf8_bom -tests/IO/encoding001.utf8 -tests/IO/encoding001.utf8.utf16 -tests/IO/encoding001.utf8.utf16be -tests/IO/encoding001.utf8.utf16le -tests/IO/encoding001.utf8.utf32 -tests/IO/encoding001.utf8.utf32be -tests/IO/encoding001.utf8.utf32le -tests/IO/encoding001.utf8.utf8_bom -tests/IO/encoding001.utf8_bom -tests/IO/encoding001.utf8_bom.utf16 -tests/IO/encoding001.utf8_bom.utf16be -tests/IO/encoding001.utf8_bom.utf16le -tests/IO/encoding001.utf8_bom.utf32 -tests/IO/encoding001.utf8_bom.utf32be -tests/IO/encoding001.utf8_bom.utf32le -tests/IO/encoding001.utf8_bom.utf8 -tests/IO/encoding002 -tests/IO/encodingerror001 -tests/IO/environment001 -tests/IO/finalization001 -tests/IO/hClose001 -tests/IO/hClose001.tmp -tests/IO/hClose002 -tests/IO/hClose002.tmp -tests/IO/hClose003 -tests/IO/hDuplicateTo001 -tests/IO/hFileSize001 -tests/IO/hFileSize002 -tests/IO/hFileSize002.out -tests/IO/hFlush001 -tests/IO/hFlush001.out -tests/IO/hGetBuf001 -tests/IO/hGetBuffering001 -tests/IO/hGetChar001 -tests/IO/hGetLine001 -tests/IO/hGetLine002 -tests/IO/hGetLine003 -tests/IO/hGetPosn001 -tests/IO/hGetPosn001.out -tests/IO/hIsEOF001 -tests/IO/hIsEOF002 -tests/IO/hIsEOF002.out -tests/IO/hReady001 -tests/IO/hReady002 -tests/IO/hSeek001 -tests/IO/hSeek002 -tests/IO/hSeek003 -tests/IO/hSeek004 -tests/IO/hSeek004.out -tests/IO/hSetBuffering002 -tests/IO/hSetBuffering003 -tests/IO/hSetBuffering004 -tests/IO/hSetEncoding001 -tests/IO/ioeGetErrorString001 -tests/IO/ioeGetFileName001 -tests/IO/ioeGetHandle001 -tests/IO/isEOF001 -tests/IO/misc001 -tests/IO/misc001.out -tests/IO/newline001 -tests/IO/newline001.out -tests/IO/openFile001 -tests/IO/openFile002 -tests/IO/openFile003 -tests/IO/openFile004 -tests/IO/openFile004.out -tests/IO/openFile005 -tests/IO/openFile005.out1 -tests/IO/openFile005.out2 -tests/IO/openFile006 -tests/IO/openFile006.out -tests/IO/openFile007 -tests/IO/openFile007.out -tests/IO/openFile008 -tests/IO/openTempFile001 -tests/IO/putStr001 -tests/IO/readFile001 -tests/IO/readFile001.out -tests/IO/readwrite001 -tests/IO/readwrite001.inout -tests/IO/readwrite002 -tests/IO/readwrite002.inout -tests/IO/readwrite003 -tests/IO/readwrite003.txt -tests/IO/tmp -tests/Numeric/.hpc/ -tests/Numeric/num001 -tests/Numeric/num002 -tests/Numeric/num003 -tests/Numeric/num004 -tests/Numeric/num005 -tests/Numeric/num006 -tests/Numeric/num007 -tests/Numeric/num008 -tests/Numeric/num009 -tests/Numeric/num010 -tests/System/.hpc/ -tests/System/exitWith001 -tests/System/getArgs001 -tests/System/getEnv001 -tests/System/system001 -tests/Text.Printf/.hpc/ -tests/Text.Printf/1548 -tests/addr001 -tests/assert -tests/char001 -tests/char002 -tests/cstring001 -tests/data-fixed-show-read -tests/dynamic001 -tests/dynamic002 -tests/dynamic003 -tests/dynamic004 -tests/dynamic005 -tests/echo001 -tests/enum01 -tests/enum02 -tests/enum03 -tests/enum04 -tests/enumDouble -tests/enumRatio -tests/exceptionsrun001 -tests/exceptionsrun002 -tests/fixed -tests/genericNegative001 -tests/hGetBuf002 -tests/hGetBuf003 -tests/hPutBuf001 -tests/hPutBuf002 -tests/hPutBuf002.out -tests/hTell001 -tests/hTell002 -tests/hash001 -tests/ioref001 -tests/ix001 -tests/length001 -tests/lex001 -tests/list001 -tests/list002 -tests/list003 -tests/memo001 -tests/memo002 -tests/performGC001 -tests/quotOverflow -tests/rand001 -tests/ratio001 -tests/readDouble001 -tests/readFloat -tests/readInteger001 -tests/readLitChar -tests/reads001 -tests/show001 -tests/showDouble -tests/stableptr001 -tests/stableptr003 -tests/stableptr004 -tests/stableptr005 -tests/take001 -tests/tempfiles -tests/text001 -tests/trace001 -tests/tup001 -tests/unicode001 -tests/unicode002 -tests/weak001 - diff --git a/libraries/base/Control/Concurrent.hs b/libraries/base/Control/Concurrent.hs index c487190f27..e5a0ebfe20 100644 --- a/libraries/base/Control/Concurrent.hs +++ b/libraries/base/Control/Concurrent.hs @@ -361,8 +361,8 @@ is /bound/, an unbound thread is created temporarily using 'forkIO'. Use this function /only/ in the rare case that you have actually observed a performance loss due to the use of bound threads. A program that -doesn't need it's main thread to be bound and makes /heavy/ use of concurrency -(e.g. a web server), might want to wrap it's @main@ action in +doesn't need its main thread to be bound and makes /heavy/ use of concurrency +(e.g. a web server), might want to wrap its @main@ action in @runInUnboundThread@. Note that exceptions which are thrown to the current thread are thrown in turn diff --git a/libraries/base/Control/Concurrent/Chan.hs b/libraries/base/Control/Concurrent/Chan.hs index 32387da5bf..e0b7b54c23 100644 --- a/libraries/base/Control/Concurrent/Chan.hs +++ b/libraries/base/Control/Concurrent/Chan.hs @@ -1,6 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} -{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} +{-# LANGUAGE AutoDeriveTypeable, StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | diff --git a/libraries/base/Control/Concurrent/QSem.hs b/libraries/base/Control/Concurrent/QSem.hs index 2761ef2bb1..223d86539d 100644 --- a/libraries/base/Control/Concurrent/QSem.hs +++ b/libraries/base/Control/Concurrent/QSem.hs @@ -1,5 +1,5 @@ {-# LANGUAGE Trustworthy #-} -{-# LANGUAGE DeriveDataTypeable, BangPatterns #-} +{-# LANGUAGE AutoDeriveTypeable, BangPatterns #-} {-# OPTIONS_GHC -funbox-strict-fields #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Control/Concurrent/QSemN.hs b/libraries/base/Control/Concurrent/QSemN.hs index 546b8f945e..a377e5e804 100644 --- a/libraries/base/Control/Concurrent/QSemN.hs +++ b/libraries/base/Control/Concurrent/QSemN.hs @@ -1,5 +1,5 @@ {-# LANGUAGE Trustworthy #-} -{-# LANGUAGE DeriveDataTypeable, BangPatterns #-} +{-# LANGUAGE AutoDeriveTypeable, BangPatterns #-} {-# OPTIONS_GHC -funbox-strict-fields #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Control/Exception/Base.hs b/libraries/base/Control/Exception/Base.hs index d8a0d9635f..8df4958cbb 100644 --- a/libraries/base/Control/Exception/Base.hs +++ b/libraries/base/Control/Exception/Base.hs @@ -1,6 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude, MagicHash #-} -{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} +{-# LANGUAGE AutoDeriveTypeable, StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | diff --git a/libraries/base/Control/Monad.hs b/libraries/base/Control/Monad.hs index 19c9a87bde..00c1fdda37 100644 --- a/libraries/base/Control/Monad.hs +++ b/libraries/base/Control/Monad.hs @@ -74,6 +74,9 @@ module Control.Monad , ap + -- ** Strict monadic functions + + , (<$!>) ) where import Data.Maybe @@ -311,6 +314,18 @@ is equivalent to ap :: (Monad m) => m (a -> b) -> m a -> m b ap = liftM2 id +infixl 4 <$!> + +-- | Strict version of 'Data.Functor.<$>'. +-- +-- /Since: 4.7.1.0/ +(<$!>) :: Monad m => (a -> b) -> m a -> m b +{-# INLINE (<$!>) #-} +f <$!> m = do + x <- m + let z = f x + z `seq` return z + -- ----------------------------------------------------------------------------- -- Other MonadPlus functions diff --git a/libraries/base/Data/Coerce.hs b/libraries/base/Data/Coerce.hs index bf269f5ea8..653a857da8 100644 --- a/libraries/base/Data/Coerce.hs +++ b/libraries/base/Data/Coerce.hs @@ -1,6 +1,5 @@ {-# LANGUAGE Unsafe #-} -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE NoImplicitPrelude #-} ----------------------------------------------------------------------------- -- | @@ -26,3 +25,6 @@ module Data.Coerce ) where import GHC.Prim (coerce) import GHC.Types (Coercible) + +import GHC.Base () -- for build ordering + diff --git a/libraries/base/Data/Complex.hs b/libraries/base/Data/Complex.hs index af593cda2f..0ce148788d 100644 --- a/libraries/base/Data/Complex.hs +++ b/libraries/base/Data/Complex.hs @@ -1,5 +1,5 @@ {-# LANGUAGE Trustworthy #-} -{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE AutoDeriveTypeable #-} {-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Data.hs b/libraries/base/Data/Data.hs index a12a6d7144..49407fae16 100644 --- a/libraries/base/Data/Data.hs +++ b/libraries/base/Data/Data.hs @@ -1,6 +1,6 @@ {-# LANGUAGE Trustworthy, FlexibleInstances #-} {-# LANGUAGE RankNTypes, ScopedTypeVariables, PolyKinds #-} -{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable, TypeOperators, +{-# LANGUAGE StandaloneDeriving, AutoDeriveTypeable, TypeOperators, GADTs #-} ----------------------------------------------------------------------------- @@ -323,7 +323,7 @@ class Typeable a => Data a where -- | A generic query that processes the immediate subterms and returns a list -- of results. The list is given in the same order as originally specified - -- in the declaratoin of the data constructors. + -- in the declaration of the data constructors. gmapQ :: (forall d. Data d => d -> u) -> a -> [u] gmapQ f = gmapQr (:) [] f @@ -777,12 +777,12 @@ mkCharConstr dt c = case datarep dt of ------------------------------------------------------------------------------ -- --- Non-representations for non-presentable types +-- Non-representations for non-representable types -- ------------------------------------------------------------------------------ --- | Constructs a non-representation for a non-presentable type +-- | Constructs a non-representation for a non-representable type mkNoRepType :: String -> DataType mkNoRepType str = DataType { tycon = str diff --git a/libraries/base/Data/Dynamic.hs b/libraries/base/Data/Dynamic.hs index 7d49a06bc3..50bea62e1a 100644 --- a/libraries/base/Data/Dynamic.hs +++ b/libraries/base/Data/Dynamic.hs @@ -1,6 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} -{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} +{-# LANGUAGE AutoDeriveTypeable, StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | diff --git a/libraries/base/Data/Either.hs b/libraries/base/Data/Either.hs index cf45e79456..9abb20522c 100644 --- a/libraries/base/Data/Either.hs +++ b/libraries/base/Data/Either.hs @@ -1,6 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude #-} -{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} +{-# LANGUAGE AutoDeriveTypeable, StandaloneDeriving #-} {-# LANGUAGE PolyKinds, DataKinds, TypeFamilies, TypeOperators, UndecidableInstances #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Fixed.hs b/libraries/base/Data/Fixed.hs index f5fb896c38..cadbb61ac1 100644 --- a/libraries/base/Data/Fixed.hs +++ b/libraries/base/Data/Fixed.hs @@ -1,6 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE AutoDeriveTypeable #-} {-# OPTIONS -Wall -fno-warn-unused-binds #-} ----------------------------------------------------------------------------- @@ -158,9 +158,13 @@ instance (HasResolution a) => Read (Fixed a) where convertFixed :: forall a . HasResolution a => Lexeme -> ReadPrec (Fixed a) convertFixed (Number n) - | Just (i, f) <- numberToFixed r n = - return (fromInteger i + (fromInteger f / (10 ^ r))) + | Just (i, f) <- numberToFixed e n = + return (fromInteger i + (fromInteger f / (10 ^ e))) where r = resolution (undefined :: Fixed a) + -- round 'e' up to help make the 'read . show == id' property + -- possible also for cases where 'resolution' is not a + -- power-of-10, such as e.g. when 'resolution = 128' + e = ceiling (logBase 10 (fromInteger r) :: Double) convertFixed _ = pfail data E0 = E0 diff --git a/libraries/base/Data/Type/Equality.hs b/libraries/base/Data/Type/Equality.hs index 464f7d28dd..626e817b30 100644 --- a/libraries/base/Data/Type/Equality.hs +++ b/libraries/base/Data/Type/Equality.hs @@ -127,6 +127,61 @@ instance TestEquality ((:~:) a) where type family (a :: k) == (b :: k) :: Bool infix 4 == +{- +This comment explains more about why a poly-kinded instance for (==) is +not provided. To be concrete, here would be the poly-kinded instance: + +type family EqPoly (a :: k) (b :: k) where + EqPoly a a = True + EqPoly a b = False +type instance (a :: k) == (b :: k) = EqPoly a b + +Note that this overlaps with every other instance -- if this were defined, +it would be the only instance for (==). + +Now, consider +data Nat = Zero | Succ Nat + +Suppose I want +foo :: (Succ n == Succ m) ~ True => ((n == m) :~: True) +foo = Refl + +This would not type-check with the poly-kinded instance. `Succ n == Succ m` +quickly becomes `EqPoly (Succ n) (Succ m)` but then is stuck. We don't know +enough about `n` and `m` to reduce further. + +On the other hand, consider this: + +type family EqNat (a :: Nat) (b :: Nat) where + EqNat Zero Zero = True + EqNat (Succ n) (Succ m) = EqNat n m + EqNat n m = False +type instance (a :: Nat) == (b :: Nat) = EqNat a b + +With this instance, `foo` type-checks fine. `Succ n == Succ m` becomes `EqNat +(Succ n) (Succ m)` which becomes `EqNat n m`. Thus, we can conclude `(n == m) +~ True` as desired. + +So, the Nat-specific instance allows strictly more reductions, and is thus +preferable to the poly-kinded instance. But, if we introduce the poly-kinded +instance, we are barred from writing the Nat-specific instance, due to +overlap. + +Even better than the current instance for * would be one that does this sort +of recursion for all datatypes, something like this: + +type family EqStar (a :: *) (b :: *) where + EqStar Bool Bool = True + EqStar (a,b) (c,d) = a == c && b == d + EqStar (Maybe a) (Maybe b) = a == b + ... + EqStar a b = False + +The problem is the (...) is extensible -- we would want to add new cases for +all datatypes in scope. This is not currently possible for closed type +families. +-} + -- all of the following closed type families are local to this module type family EqStar (a :: *) (b :: *) where EqStar a a = True diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index fa18bf9c60..93b64ef9e9 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -1,4 +1,5 @@ {-# LANGUAGE Unsafe #-} +{-# LANGUAGE BangPatterns #-} ----------------------------------------------------------------------------- -- | @@ -22,6 +23,8 @@ , PolyKinds , ConstraintKinds , DeriveDataTypeable + , DataKinds + , UndecidableInstances , StandaloneDeriving #-} module Data.Typeable.Internal ( @@ -50,6 +53,7 @@ module Data.Typeable.Internal ( import GHC.Base import GHC.Word import GHC.Show +import GHC.Read ( Read ) import Data.Maybe import Data.Proxy import GHC.Num @@ -57,13 +61,21 @@ import GHC.Real -- import GHC.IORef -- import GHC.IOArray -- import GHC.MVar -import GHC.ST ( ST ) +import GHC.ST ( ST, STret ) import GHC.STRef ( STRef ) import GHC.Ptr ( Ptr, FunPtr ) -- import GHC.Stable -import GHC.Arr ( Array, STArray ) +import GHC.Arr ( Array, STArray, Ix ) +import GHC.TypeLits ( Nat, Symbol, KnownNat, KnownSymbol, natVal', symbolVal' ) import Data.Type.Coercion import Data.Type.Equality +import Text.ParserCombinators.ReadP ( ReadP ) +import Text.Read.Lex ( Lexeme, Number ) +import Text.ParserCombinators.ReadPrec ( ReadPrec ) +import GHC.Float ( FFFormat, RealFloat, Floating ) +import Data.Bits ( Bits, FiniteBits ) +import GHC.Enum ( Bounded, Enum ) +import Control.Monad ( MonadPlus ) -- import Data.Int import GHC.Fingerprint.Type @@ -251,8 +263,20 @@ type Typeable7 (a :: * -> * -> * -> * -> * -> * -> * -> *) = Typeable a {-# DEPRECATED Typeable7 "renamed to 'Typeable'" #-} -- deprecated in 7.8 -- | Kind-polymorphic Typeable instance for type application -instance (Typeable s, Typeable a) => Typeable (s a) where - typeRep# _ = typeRep# (proxy# :: Proxy# s) `mkAppTy` typeRep# (proxy# :: Proxy# a) +instance {-# INCOHERENT #-} (Typeable s, Typeable a) => Typeable (s a) where + typeRep# = \_ -> rep -- Note [Memoising typeOf] + where !ty1 = typeRep# (proxy# :: Proxy# s) + !ty2 = typeRep# (proxy# :: Proxy# a) + !rep = ty1 `mkAppTy` ty2 + +{- Note [Memoising typeOf] +~~~~~~~~~~~~~~~~~~~~~~~~~~ +See #3245, #9203 + +IMPORTANT: we don't want to recalculate the TypeRep once per call with +the proxy argument. This is what went wrong in #3245 and #9203. So we +help GHC by manually keeping the 'rep' *outside* the lambda. +-} ----------------- Showing TypeReps -------------------- @@ -316,6 +340,7 @@ deriving instance Typeable IO deriving instance Typeable Array deriving instance Typeable ST +deriving instance Typeable STret deriving instance Typeable STRef deriving instance Typeable STArray @@ -351,8 +376,106 @@ deriving instance Typeable Word64 deriving instance Typeable TyCon deriving instance Typeable TypeRep +deriving instance Typeable Fingerprint deriving instance Typeable RealWorld deriving instance Typeable Proxy +deriving instance Typeable KProxy deriving instance Typeable (:~:) deriving instance Typeable Coercion + +deriving instance Typeable ReadP +deriving instance Typeable Lexeme +deriving instance Typeable Number +deriving instance Typeable ReadPrec + +deriving instance Typeable FFFormat + +------------------------------------------------------- +-- +-- Generate Typeable instances for standard classes +-- +------------------------------------------------------- + +deriving instance Typeable (~) +deriving instance Typeable Coercible +deriving instance Typeable TestEquality +deriving instance Typeable TestCoercion + +deriving instance Typeable Eq +deriving instance Typeable Ord + +deriving instance Typeable Bits +deriving instance Typeable FiniteBits +deriving instance Typeable Num +deriving instance Typeable Real +deriving instance Typeable Integral +deriving instance Typeable Fractional +deriving instance Typeable RealFrac +deriving instance Typeable Floating +deriving instance Typeable RealFloat + +deriving instance Typeable Bounded +deriving instance Typeable Enum +deriving instance Typeable Ix + +deriving instance Typeable Show +deriving instance Typeable Read + +deriving instance Typeable Functor +deriving instance Typeable Monad +deriving instance Typeable MonadPlus + +deriving instance Typeable Typeable + + + +-------------------------------------------------------------------------------- +-- Instances for type literals + +{- Note [Potential Collisions in `Nat` and `Symbol` instances] + +Kinds resulting from lifted types have finitely many type-constructors. +This is not the case for `Nat` and `Symbol`, which both contain *infinitely* +many type constructors (e.g., `Nat` has 0, 1, 2, 3, etc.). One might think +that this would increase the chance of hash-collisions in the type but this +is not the case because the fingerprint stored in a `TypeRep` identifies +the whole *type* and not just the type constructor. This is why the chance +of collisions for `Nat` and `Symbol` is not any worse than it is for other +lifted types with infinitely many inhabitants. Indeed, `Nat` is +isomorphic to (lifted) `[()]` and `Symbol` is isomorphic to `[Char]`. +-} + +instance KnownNat n => Typeable (n :: Nat) where + -- See #9203 for an explanation of why this is written as `\_ -> rep`. + typeRep# = \_ -> rep + where + rep = mkTyConApp tc [] + tc = TyCon + { tyConHash = fingerprintString (mk pack modu nm) + , tyConPackage = pack + , tyConModule = modu + , tyConName = nm + } + pack = "base" + modu = "GHC.TypeLits" + nm = show (natVal' (proxy# :: Proxy# n)) + mk a b c = a ++ " " ++ b ++ " " ++ c + + +instance KnownSymbol s => Typeable (s :: Symbol) where + -- See #9203 for an explanation of why this is written as `\_ -> rep`. + typeRep# = \_ -> rep + where + rep = mkTyConApp tc [] + tc = TyCon + { tyConHash = fingerprintString (mk pack modu nm) + , tyConPackage = pack + , tyConModule = modu + , tyConName = nm + } + pack = "base" + modu = "GHC.TypeLits" + nm = show (symbolVal' (proxy# :: Proxy# s)) + mk a b c = a ++ " " ++ b ++ " " ++ c + diff --git a/libraries/base/Data/Unique.hs b/libraries/base/Data/Unique.hs index 2d30cc18e9..a5c0d6c753 100644 --- a/libraries/base/Data/Unique.hs +++ b/libraries/base/Data/Unique.hs @@ -1,5 +1,5 @@ {-# LANGUAGE Trustworthy #-} -{-# LANGUAGE MagicHash, DeriveDataTypeable #-} +{-# LANGUAGE MagicHash, AutoDeriveTypeable #-} ----------------------------------------------------------------------------- -- | diff --git a/libraries/base/Data/Version.hs b/libraries/base/Data/Version.hs index 23d217634e..8b88486571 100644 --- a/libraries/base/Data/Version.hs +++ b/libraries/base/Data/Version.hs @@ -1,5 +1,5 @@ {-# LANGUAGE Trustworthy #-} -{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE AutoDeriveTypeable #-} ----------------------------------------------------------------------------- -- | diff --git a/libraries/base/Foreign/C/Types.hs b/libraries/base/Foreign/C/Types.hs index 4aeae53df6..39ba2a868c 100644 --- a/libraries/base/Foreign/C/Types.hs +++ b/libraries/base/Foreign/C/Types.hs @@ -5,7 +5,7 @@ , GeneralizedNewtypeDeriving #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-} -{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} +{-# LANGUAGE AutoDeriveTypeable, StandaloneDeriving #-} -- XXX -fno-warn-unused-binds stops us warning about unused constructors, -- but really we should just remove them if we don't want them diff --git a/libraries/base/Foreign/ForeignPtr.hs b/libraries/base/Foreign/ForeignPtr.hs index 0017c0e8ac..2e9b9ec08a 100644 --- a/libraries/base/Foreign/ForeignPtr.hs +++ b/libraries/base/Foreign/ForeignPtr.hs @@ -1,6 +1,5 @@ {-# LANGUAGE Unsafe #-} {-# LANGUAGE NoImplicitPrelude #-} -{-# OPTIONS_HADDOCK hide #-} ----------------------------------------------------------------------------- -- | diff --git a/libraries/base/Foreign/Ptr.hs b/libraries/base/Foreign/Ptr.hs index 0d74a8269c..f35fdeb70f 100644 --- a/libraries/base/Foreign/Ptr.hs +++ b/libraries/base/Foreign/Ptr.hs @@ -4,7 +4,7 @@ , MagicHash , GeneralizedNewtypeDeriving #-} -{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} +{-# LANGUAGE AutoDeriveTypeable, StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | diff --git a/libraries/base/GHC/Base.lhs b/libraries/base/GHC/Base.lhs index 1c8e144b7f..6a089ee432 100644 --- a/libraries/base/GHC/Base.lhs +++ b/libraries/base/GHC/Base.lhs @@ -114,14 +114,8 @@ import GHC.Prim import GHC.Err import {-# SOURCE #-} GHC.IO (failIO) --- This is not strictly speaking required by this module, but is an --- implicit dependency whenever () or tuples are mentioned, so adding it --- as an import here helps to get the dependencies right in the new --- build system. -import GHC.Tuple () --- Likewise we need Integer when deriving things like Eq instances, and --- this is a convenient place to force it to be built -import GHC.Integer () +import GHC.Tuple () -- Note [Depend on GHC.Tuple] +import GHC.Integer () -- Note [Depend on GHC.Integer] infixr 9 . infixr 5 ++ @@ -132,6 +126,36 @@ infixr 0 $ default () -- Double isn't available yet \end{code} +Note [Depend on GHC.Integer] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The Integer type is special because TidyPgm uses +GHC.Integer.Type.mkInteger to construct Integer literal values +Currently it reads the interface file whether or not the current +module *has* any Integer literals, so it's important that +GHC.Integer.Type (in patckage integer-gmp or integer-simple) is +compiled before any other module. (There's a hack in GHC to disable +this for packages ghc-prim, integer-gmp, integer-simple, which aren't +allowed to contain any Integer literals.) + +Likewise we implicitly need Integer when deriving things like Eq +instances. + +The danger is that if the build system doesn't know about the dependency +on Integer, it'll compile some base module before GHC.Integer.Type, +resulting in: + Failed to load interface for ‘GHC.Integer.Type’ + There are files missing in the ‘integer-gmp’ package, + +Bottom line: we make GHC.Base depend on GHC.Integer; and everything +else either depends on GHC.Base, or does not have NoImplicitPrelude +(and hence depends on Prelude). + +Note [Depend on GHC.Tuple] +~~~~~~~~~~~~~~~~~~~~~~~~~~ +Similarly, tuple syntax (or ()) creates an implicit dependency on +GHC.Tuple, so we use the same rule as for Integer --- see Note [Depend on +GHC.Integer] --- to explain this to the build system. We make GHC.Base +depend on GHC.Tuple, and everything else depends on GHC.Base or Prelude. %********************************************************* %* * @@ -406,7 +430,7 @@ mapFB c f = \x ys -> c (f x) ys -- -- http://research.microsoft.com/en-us/um/people/simonpj/papers/ext-f/coercible.pdf -{-# RULES "map/coerce" map coerce = coerce #-} +{-# RULES "map/coerce" [1] map coerce = coerce #-} \end{code} diff --git a/libraries/base/GHC/Conc/Sync.lhs b/libraries/base/GHC/Conc/Sync.lhs index ebb7226d09..713e0b5c3b 100644 --- a/libraries/base/GHC/Conc/Sync.lhs +++ b/libraries/base/GHC/Conc/Sync.lhs @@ -219,10 +219,10 @@ forkIOWithUnmask :: ((forall a . IO a -> IO a) -> IO ()) -> IO ThreadId forkIOWithUnmask io = forkIO (io unsafeUnmask) {- | -Like 'forkIO', but lets you specify on which processor the thread +Like 'forkIO', but lets you specify on which capability the thread should run. Unlike a `forkIO` thread, a thread created by `forkOn` -will stay on the same processor for its entire lifetime (`forkIO` -threads can migrate between processors according to the scheduling +will stay on the same capability for its entire lifetime (`forkIO` +threads can migrate between capabilities according to the scheduling policy). `forkOn` is useful for overriding the scheduling policy when you know in advance how best to distribute the threads. diff --git a/libraries/base/GHC/Conc/Windows.hs b/libraries/base/GHC/Conc/Windows.hs index ad60a07d40..c01281ac68 100644 --- a/libraries/base/GHC/Conc/Windows.hs +++ b/libraries/base/GHC/Conc/Windows.hs @@ -1,5 +1,5 @@ {-# LANGUAGE Trustworthy #-} -{-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, UnboxedTuples, DeriveDataTypeable #-} +{-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, UnboxedTuples, AutoDeriveTypeable #-} {-# OPTIONS_GHC -fno-warn-missing-signatures #-} {-# OPTIONS_HADDOCK not-home #-} diff --git a/libraries/base/GHC/Enum.lhs b/libraries/base/GHC/Enum.lhs index fe2e6b6a71..d94e2ec54b 100644 --- a/libraries/base/GHC/Enum.lhs +++ b/libraries/base/GHC/Enum.lhs @@ -705,7 +705,7 @@ enumDeltaToIntegerFB c n x delta lim "enumDeltaToInteger1" [0] forall c n x . enumDeltaToIntegerFB c n x 1 = up_fb c n x 1 #-} -- This rule ensures that in the common case (delta = 1), we do not do the check here, --- and also that we have the chance to inline up_fb, which would allow the constuctor to be +-- and also that we have the chance to inline up_fb, which would allow the constructor to be -- inlined and good things to happen. -- We do not do it for Int this way because hand-tuned code already exists, and -- the special case varies more from the general case, due to the issue of overflows. diff --git a/libraries/base/GHC/Event.hs b/libraries/base/GHC/Event.hs index b49645e5fe..9746bc7f2e 100644 --- a/libraries/base/GHC/Event.hs +++ b/libraries/base/GHC/Event.hs @@ -11,6 +11,7 @@ module GHC.Event ( -- * Types EventManager + , TimerManager -- * Creation , getSystemEventManager @@ -39,6 +40,6 @@ module GHC.Event import GHC.Event.Manager import GHC.Event.TimerManager (TimeoutCallback, TimeoutKey, registerTimeout, - updateTimeout, unregisterTimeout) + updateTimeout, unregisterTimeout, TimerManager) import GHC.Event.Thread (getSystemEventManager, getSystemTimerManager) diff --git a/libraries/base/GHC/Event/Poll.hsc b/libraries/base/GHC/Event/Poll.hsc index bb0b6e570b..2ed25bec8b 100644 --- a/libraries/base/GHC/Event/Poll.hsc +++ b/libraries/base/GHC/Event/Poll.hsc @@ -14,6 +14,7 @@ module GHC.Event.Poll #if !defined(HAVE_POLL_H) import GHC.Base +import qualified GHC.Event.Internal as E new :: IO E.Backend new = error "Poll back end not implemented for this platform" diff --git a/libraries/base/GHC/Event/Thread.hs b/libraries/base/GHC/Event/Thread.hs index c599047db6..6e991bfb6c 100644 --- a/libraries/base/GHC/Event/Thread.hs +++ b/libraries/base/GHC/Event/Thread.hs @@ -12,9 +12,10 @@ module GHC.Event.Thread , closeFdWith , threadDelay , registerDelay + , blockedOnBadFD -- used by RTS ) where -import Control.Exception (finally) +import Control.Exception (finally, SomeException, toException) import Control.Monad (forM, forM_, sequence_, zipWithM, when) import Data.IORef (IORef, newIORef, readIORef, writeIORef) import Data.List (zipWith3) @@ -115,6 +116,9 @@ threadWait evt fd = mask_ $ do then ioError $ errnoToIOError "threadWait" eBADF Nothing Nothing else return () +-- used at least by RTS in 'select()' IO manager backend +blockedOnBadFD :: SomeException +blockedOnBadFD = toException $ errnoToIOError "awaitEvent" eBADF Nothing Nothing threadWaitSTM :: Event -> Fd -> IO (STM (), IO ()) threadWaitSTM evt fd = mask_ $ do diff --git a/libraries/base/GHC/Event/TimerManager.hs b/libraries/base/GHC/Event/TimerManager.hs index f94f06148a..f581330e25 100644 --- a/libraries/base/GHC/Event/TimerManager.hs +++ b/libraries/base/GHC/Event/TimerManager.hs @@ -98,7 +98,7 @@ become roots for all subsequent minor GCs. When the thunks eventually get evaluated they will each create a new intermediate 'TimeoutQueue' that immediately becomes garbage. Since the thunks serve as roots until the next major GC these intermediate -'TimeoutQueue's will get copied unnecesarily in the next minor GC, +'TimeoutQueue's will get copied unnecessarily in the next minor GC, increasing GC time. This problem is known as "floating garbage". Keeping a list of edits doesn't stop this from happening but makes the diff --git a/libraries/base/GHC/Exts.hs b/libraries/base/GHC/Exts.hs index 05e72811c8..938631001a 100755 --- a/libraries/base/GHC/Exts.hs +++ b/libraries/base/GHC/Exts.hs @@ -1,5 +1,5 @@ {-# LANGUAGE Unsafe #-} -{-# LANGUAGE MagicHash, UnboxedTuples, DeriveDataTypeable, TypeFamilies, MultiParamTypeClasses, FlexibleInstances #-} +{-# LANGUAGE MagicHash, UnboxedTuples, AutoDeriveTypeable, TypeFamilies, MultiParamTypeClasses, FlexibleInstances #-} ----------------------------------------------------------------------------- -- | diff --git a/libraries/base/GHC/ForeignPtr.hs b/libraries/base/GHC/ForeignPtr.hs index 58b4f9a3fa..fe7293e41e 100644 --- a/libraries/base/GHC/ForeignPtr.hs +++ b/libraries/base/GHC/ForeignPtr.hs @@ -5,7 +5,7 @@ , UnboxedTuples #-} {-# OPTIONS_HADDOCK hide #-} -{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} +{-# LANGUAGE AutoDeriveTypeable, StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | diff --git a/libraries/base/GHC/IO/Exception.hs b/libraries/base/GHC/IO/Exception.hs index 7f5bc4ef18..e7e3316ca9 100644 --- a/libraries/base/GHC/IO/Exception.hs +++ b/libraries/base/GHC/IO/Exception.hs @@ -1,5 +1,5 @@ {-# LANGUAGE Trustworthy #-} -{-# LANGUAGE NoImplicitPrelude, DeriveDataTypeable, MagicHash, +{-# LANGUAGE NoImplicitPrelude, AutoDeriveTypeable, MagicHash, ExistentialQuantification #-} {-# OPTIONS_GHC -funbox-strict-fields #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/GHC/IO/FD.hs b/libraries/base/GHC/IO/FD.hs index 2023526e55..7b30504f8e 100644 --- a/libraries/base/GHC/IO/FD.hs +++ b/libraries/base/GHC/IO/FD.hs @@ -2,7 +2,7 @@ {-# LANGUAGE CPP , NoImplicitPrelude , BangPatterns - , DeriveDataTypeable + , AutoDeriveTypeable #-} {-# OPTIONS_GHC -fno-warn-identities #-} -- Whether there are identities depends on the platform diff --git a/libraries/base/GHC/IO/Handle/Types.hs b/libraries/base/GHC/IO/Handle/Types.hs index ec8f453cb6..defa33bbca 100644 --- a/libraries/base/GHC/IO/Handle/Types.hs +++ b/libraries/base/GHC/IO/Handle/Types.hs @@ -2,7 +2,7 @@ {-# LANGUAGE CPP , NoImplicitPrelude , ExistentialQuantification - , DeriveDataTypeable + , AutoDeriveTypeable #-} {-# OPTIONS_GHC -funbox-strict-fields #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/GHC/IOArray.hs b/libraries/base/GHC/IOArray.hs index 8594e2ada5..ff9e545817 100644 --- a/libraries/base/GHC/IOArray.hs +++ b/libraries/base/GHC/IOArray.hs @@ -1,5 +1,5 @@ {-# LANGUAGE Unsafe #-} -{-# LANGUAGE NoImplicitPrelude, DeriveDataTypeable #-} +{-# LANGUAGE NoImplicitPrelude, AutoDeriveTypeable #-} {-# OPTIONS_GHC -funbox-strict-fields #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/GHC/IORef.hs b/libraries/base/GHC/IORef.hs index bb618341b4..154c30cd8d 100644 --- a/libraries/base/GHC/IORef.hs +++ b/libraries/base/GHC/IORef.hs @@ -1,5 +1,5 @@ {-# LANGUAGE Unsafe #-} -{-# LANGUAGE NoImplicitPrelude, MagicHash, DeriveDataTypeable #-} +{-# LANGUAGE NoImplicitPrelude, MagicHash, AutoDeriveTypeable #-} {-# OPTIONS_GHC -funbox-strict-fields #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/GHC/IP.hs b/libraries/base/GHC/IP.hs index 4794c05452..95b00c15ff 100644 --- a/libraries/base/GHC/IP.hs +++ b/libraries/base/GHC/IP.hs @@ -2,7 +2,7 @@ {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE DataKinds #-} -{-# OPTIONS_GHC -XNoImplicitPrelude #-} +{-# LANGUAGE NoImplicitPrelude #-} -- | /Since: 4.6.0.0/ module GHC.IP (IP(..)) where diff --git a/libraries/base/GHC/Int.hs b/libraries/base/GHC/Int.hs index 899d9ad712..467b3f4e30 100644 --- a/libraries/base/GHC/Int.hs +++ b/libraries/base/GHC/Int.hs @@ -1,6 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns, MagicHash, UnboxedTuples, - StandaloneDeriving, DeriveDataTypeable, NegativeLiterals #-} + StandaloneDeriving, AutoDeriveTypeable, NegativeLiterals #-} {-# OPTIONS_HADDOCK hide #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/GHC/MVar.hs b/libraries/base/GHC/MVar.hs index 03facad608..ff138a5ef2 100644 --- a/libraries/base/GHC/MVar.hs +++ b/libraries/base/GHC/MVar.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE Unsafe, DeriveDataTypeable #-} +{-# LANGUAGE Unsafe, AutoDeriveTypeable #-} {-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples #-} {-# OPTIONS_GHC -funbox-strict-fields #-} {-# OPTIONS_HADDOCK hide #-} diff --git a/libraries/base/GHC/Ptr.lhs b/libraries/base/GHC/Ptr.lhs index c959d1e375..a55f01e9b1 100644 --- a/libraries/base/GHC/Ptr.lhs +++ b/libraries/base/GHC/Ptr.lhs @@ -37,7 +37,12 @@ import Numeric ( showHex ) ------------------------------------------------------------------------ -- Data pointers. -type role Ptr representational +-- The role of Ptr's parameter is phantom, as there is no relation between +-- the Haskell representation and whathever the user puts at the end of the +-- pointer. And phantom is useful to implement castPtr (see #9163) + +-- redundant role annotation checks that this doesn't change +type role Ptr phantom data Ptr a = Ptr Addr# deriving (Eq, Ord) -- ^ A value of type @'Ptr' a@ represents a pointer to an object, or an -- array of objects, which may be marshalled to or from Haskell values @@ -56,7 +61,7 @@ nullPtr = Ptr nullAddr# -- |The 'castPtr' function casts a pointer from one type to another. castPtr :: Ptr a -> Ptr b -castPtr (Ptr addr) = Ptr addr +castPtr = coerce -- |Advances the given address by the given offset in bytes. plusPtr :: Ptr a -> Int -> Ptr b @@ -82,7 +87,10 @@ minusPtr (Ptr a1) (Ptr a2) = I# (minusAddr# a1 a2) ------------------------------------------------------------------------ -- Function pointers for the default calling convention. -type role FunPtr representational +-- 'FunPtr' has a phantom role for similar reasons to 'Ptr'. Note +-- that 'FunPtr's role cannot become nominal without changes elsewhere +-- in GHC. See Note [FFI type roles] in TcForeign. +type role FunPtr phantom data FunPtr a = FunPtr Addr# deriving (Eq, Ord) -- ^ A value of type @'FunPtr' a@ is a pointer to a function callable -- from foreign code. The type @a@ will normally be a /foreign type/, @@ -132,7 +140,7 @@ nullFunPtr = FunPtr nullAddr# -- |Casts a 'FunPtr' to a 'FunPtr' of a different type. castFunPtr :: FunPtr a -> FunPtr b -castFunPtr (FunPtr addr) = FunPtr addr +castFunPtr = coerce -- |Casts a 'FunPtr' to a 'Ptr'. -- diff --git a/libraries/base/GHC/TypeLits.hs b/libraries/base/GHC/TypeLits.hs index 083ae4d144..7ae6fb0422 100644 --- a/libraries/base/GHC/TypeLits.hs +++ b/libraries/base/GHC/TypeLits.hs @@ -9,7 +9,9 @@ {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE UndecidableInstances #-} -- for compiling instances of (==) -{-# OPTIONS_GHC -XNoImplicitPrelude #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE MagicHash #-} + {-| This module is an internal GHC module. It declares the constants used in the implementation of type-level natural numbers. The programmer interface for working with type-level naturals should be defined in a separate library. @@ -22,8 +24,8 @@ module GHC.TypeLits Nat, Symbol -- * Linking type and value level - , KnownNat, natVal - , KnownSymbol, symbolVal + , KnownNat, natVal, natVal' + , KnownSymbol, symbolVal, symbolVal' , SomeNat(..), SomeSymbol(..) , someNatVal, someSymbolVal , sameNat, sameSymbol @@ -40,9 +42,9 @@ import GHC.Num(Integer) import GHC.Base(String) import GHC.Show(Show(..)) import GHC.Read(Read(..)) -import GHC.Prim(magicDict) +import GHC.Prim(magicDict, Proxy#) import Data.Maybe(Maybe(..)) -import Data.Proxy(Proxy(..)) +import Data.Proxy (Proxy(..)) import Data.Type.Equality(type (==), (:~:)(Refl)) import Unsafe.Coerce(unsafeCoerce) @@ -79,6 +81,16 @@ symbolVal :: forall n proxy. KnownSymbol n => proxy n -> String symbolVal _ = case symbolSing :: SSymbol n of SSymbol x -> x +-- | /Since: 4.7.1.0/ +natVal' :: forall n. KnownNat n => Proxy# n -> Integer +natVal' _ = case natSing :: SNat n of + SNat x -> x + +-- | /Since: 4.7.1.0/ +symbolVal' :: forall n. KnownSymbol n => Proxy# n -> String +symbolVal' _ = case symbolSing :: SSymbol n of + SSymbol x -> x + -- | This type represents unknown type-level natural numbers. diff --git a/libraries/base/System/Mem/StableName.hs b/libraries/base/System/Mem/StableName.hs index 7d080d9247..4f2cab81f8 100644 --- a/libraries/base/System/Mem/StableName.hs +++ b/libraries/base/System/Mem/StableName.hs @@ -1,6 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} -{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} +{-# LANGUAGE AutoDeriveTypeable, StandaloneDeriving #-} {-# LANGUAGE MagicHash #-} #if !defined(__PARALLEL_HASKELL__) {-# LANGUAGE UnboxedTuples #-} diff --git a/libraries/base/System/Posix/Types.hs b/libraries/base/System/Posix/Types.hs index aa159155c0..8b95699b27 100644 --- a/libraries/base/System/Posix/Types.hs +++ b/libraries/base/System/Posix/Types.hs @@ -4,7 +4,7 @@ , MagicHash , GeneralizedNewtypeDeriving #-} -{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} +{-# LANGUAGE AutoDeriveTypeable, StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | diff --git a/libraries/base/System/Timeout.hs b/libraries/base/System/Timeout.hs index 59e6647b0e..322a842392 100644 --- a/libraries/base/System/Timeout.hs +++ b/libraries/base/System/Timeout.hs @@ -1,6 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} -{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} +{-# LANGUAGE AutoDeriveTypeable, StandaloneDeriving #-} ------------------------------------------------------------------------------- -- | diff --git a/libraries/base/base.cabal b/libraries/base/base.cabal index a70a661920..e56724ce4f 100644 --- a/libraries/base/base.cabal +++ b/libraries/base/base.cabal @@ -48,6 +48,7 @@ Flag integer-simple Library default-language: Haskell2010 other-extensions: + AutoDeriveTypeable BangPatterns CApiFFI CPP diff --git a/libraries/base/cbits/inputReady.c b/libraries/base/cbits/inputReady.c index 51f278feb1..dac9d9b524 100644 --- a/libraries/base/cbits/inputReady.c +++ b/libraries/base/cbits/inputReady.c @@ -25,7 +25,11 @@ fdReady(int fd, int write, int msecs, int isSock) int maxfd, ready; fd_set rfd, wfd; struct timeval tv; - + if ((fd >= (int)FD_SETSIZE) || (fd < 0)) { + /* avoid memory corruption on too large FDs */ + errno = EINVAL; + return -1; + } FD_ZERO(&rfd); FD_ZERO(&wfd); if (write) { diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index c561165024..46006b134c 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -12,6 +12,21 @@ * Weaken RealFloat constraints on some `Data.Complex` functions + * Add `Control.Monad.(<$!>)` as a strict version of `(<$>)` + +## 4.7.0.1 *Jul 2014* + + * Bundled with GHC 7.8.3 + + * Unhide `Foreign.ForeignPtr` in Haddock (#8475) + + * Fix recomputation of `TypeRep` in `Typeable` type-application instance + (#9203) + + * Fix regression in Data.Fixed Read instance (#9231) + + * Fix `fdReady` to honor `FD_SETSIZE` (#9168) + ## 4.7.0.0 *Apr 2014* * Bundled with GHC 7.8.1 diff --git a/libraries/base/tests/.gitignore b/libraries/base/tests/.gitignore new file mode 100644 index 0000000000..b7b2dc8e76 --- /dev/null +++ b/libraries/base/tests/.gitignore @@ -0,0 +1,271 @@ +*.eventlog +*.genscript + +*.stderr.normalised +*.stdout.normalised +*.comp.stderr +*.comp.stdout +*.interp.stderr +*.interp.stdout +*.run.stderr +*.run.stdout + +.hpc.*/ +.hpc/ + +# specific files +/CPUTime001 +/Concurrent/4876 +/Concurrent/Chan002 +/Concurrent/Chan003 +/Concurrent/ThreadDelay001 +/IO/IOError001 +/IO/IOError002 +/IO/T2122 +/IO/T2122-test +/IO/T3307 +/IO/T4144 +/IO/T4808 +/IO/T4808.test +/IO/T4855 +/IO/T4895 +/IO/T7853 +/IO/chinese-file-* +/IO/chinese-name +/IO/concio002 +/IO/countReaders001 +/IO/countReaders001.txt +/IO/decodingerror001 +/IO/decodingerror002 +/IO/encoding001 +/IO/encoding001.utf16 +/IO/encoding001.utf16.utf16be +/IO/encoding001.utf16.utf16le +/IO/encoding001.utf16.utf32 +/IO/encoding001.utf16.utf32be +/IO/encoding001.utf16.utf32le +/IO/encoding001.utf16.utf8 +/IO/encoding001.utf16.utf8_bom +/IO/encoding001.utf16be +/IO/encoding001.utf16be.utf16 +/IO/encoding001.utf16be.utf16le +/IO/encoding001.utf16be.utf32 +/IO/encoding001.utf16be.utf32be +/IO/encoding001.utf16be.utf32le +/IO/encoding001.utf16be.utf8 +/IO/encoding001.utf16be.utf8_bom +/IO/encoding001.utf16le +/IO/encoding001.utf16le.utf16 +/IO/encoding001.utf16le.utf16be +/IO/encoding001.utf16le.utf32 +/IO/encoding001.utf16le.utf32be +/IO/encoding001.utf16le.utf32le +/IO/encoding001.utf16le.utf8 +/IO/encoding001.utf16le.utf8_bom +/IO/encoding001.utf32 +/IO/encoding001.utf32.utf16 +/IO/encoding001.utf32.utf16be +/IO/encoding001.utf32.utf16le +/IO/encoding001.utf32.utf32be +/IO/encoding001.utf32.utf32le +/IO/encoding001.utf32.utf8 +/IO/encoding001.utf32.utf8_bom +/IO/encoding001.utf32be +/IO/encoding001.utf32be.utf16 +/IO/encoding001.utf32be.utf16be +/IO/encoding001.utf32be.utf16le +/IO/encoding001.utf32be.utf32 +/IO/encoding001.utf32be.utf32le +/IO/encoding001.utf32be.utf8 +/IO/encoding001.utf32be.utf8_bom +/IO/encoding001.utf32le +/IO/encoding001.utf32le.utf16 +/IO/encoding001.utf32le.utf16be +/IO/encoding001.utf32le.utf16le +/IO/encoding001.utf32le.utf32 +/IO/encoding001.utf32le.utf32be +/IO/encoding001.utf32le.utf8 +/IO/encoding001.utf32le.utf8_bom +/IO/encoding001.utf8 +/IO/encoding001.utf8.utf16 +/IO/encoding001.utf8.utf16be +/IO/encoding001.utf8.utf16le +/IO/encoding001.utf8.utf32 +/IO/encoding001.utf8.utf32be +/IO/encoding001.utf8.utf32le +/IO/encoding001.utf8.utf8_bom +/IO/encoding001.utf8_bom +/IO/encoding001.utf8_bom.utf16 +/IO/encoding001.utf8_bom.utf16be +/IO/encoding001.utf8_bom.utf16le +/IO/encoding001.utf8_bom.utf32 +/IO/encoding001.utf8_bom.utf32be +/IO/encoding001.utf8_bom.utf32le +/IO/encoding001.utf8_bom.utf8 +/IO/encoding002 +/IO/encoding003 +/IO/encoding004 +/IO/encodingerror001 +/IO/environment001 +/IO/finalization001 +/IO/hClose001 +/IO/hClose001.tmp +/IO/hClose002 +/IO/hClose002.tmp +/IO/hClose003 +/IO/hDuplicateTo001 +/IO/hFileSize001 +/IO/hFileSize002 +/IO/hFileSize002.out +/IO/hFlush001 +/IO/hFlush001.out +/IO/hGetBuf001 +/IO/hGetBuffering001 +/IO/hGetChar001 +/IO/hGetLine001 +/IO/hGetLine002 +/IO/hGetLine003 +/IO/hGetPosn001 +/IO/hGetPosn001.out +/IO/hIsEOF001 +/IO/hIsEOF002 +/IO/hIsEOF002.out +/IO/hReady001 +/IO/hReady002 +/IO/hSeek001 +/IO/hSeek002 +/IO/hSeek003 +/IO/hSeek004 +/IO/hSeek004.out +/IO/hSetBuffering002 +/IO/hSetBuffering003 +/IO/hSetBuffering004 +/IO/hSetEncoding001 +/IO/ioeGetErrorString001 +/IO/ioeGetFileName001 +/IO/ioeGetHandle001 +/IO/isEOF001 +/IO/misc001 +/IO/misc001.out +/IO/newline001 +/IO/newline001.out +/IO/openFile001 +/IO/openFile002 +/IO/openFile003 +/IO/openFile003Dir +/IO/openFile004 +/IO/openFile004.out +/IO/openFile005 +/IO/openFile005.out1 +/IO/openFile005.out2 +/IO/openFile006 +/IO/openFile006.out +/IO/openFile007 +/IO/openFile007.out +/IO/openFile008 +/IO/openTempFile001 +/IO/putStr001 +/IO/readFile001 +/IO/readFile001.out +/IO/readwrite001 +/IO/readwrite001.inout +/IO/readwrite002 +/IO/readwrite002.inout +/IO/readwrite003 +/IO/readwrite003.txt +/IO/tmp +/Numeric/num001 +/Numeric/num002 +/Numeric/num003 +/Numeric/num004 +/Numeric/num005 +/Numeric/num006 +/Numeric/num007 +/Numeric/num008 +/Numeric/num009 +/Numeric/num010 +/System/T5930 +/System/Timeout001 +/System/exitWith001 +/System/getArgs001 +/System/getEnv001 +/System/system001 +/T4006 +/T5943 +/T5962 +/T7034 +/T7457 +/T7653 +/T7773 +/T7787 +/T8766 +/T8766.stats +/Text.Printf/T1548 +/addr001 +/assert +/char001 +/char002 +/cstring001 +/data-fixed-show-read +/dynamic001 +/dynamic002 +/dynamic003 +/dynamic004 +/dynamic005 +/echo001 +/enum01 +/enum02 +/enum03 +/enum04 +/enumDouble +/enumRatio +/exceptionsrun001 +/exceptionsrun002 +/fixed +/genericNegative001 +/hGetBuf002 +/hGetBuf003 +/hPutBuf001 +/hPutBuf002 +/hPutBuf002.out +/hTell001 +/hTell002 +/hash001 +/ioref001 +/ix001 +/length001 +/lex001 +/list001 +/list002 +/list003 +/memo001 +/memo002 +/performGC001 +/qsem001 +/qsemn001 +/quotOverflow +/rand001 +/ratio001 +/readDouble001 +/readFixed001 +/readFloat +/readInteger001 +/readLitChar +/reads001 +/show001 +/showDouble +/stableptr001 +/stableptr003 +/stableptr004 +/stableptr005 +/take001 +/tempfiles +/text001 +/topHandler01 +/topHandler02 +/topHandler03 +/trace001 +/tup001 +/unicode001 +/unicode002 +/weak001 diff --git a/libraries/base/tests/IO/all.T b/libraries/base/tests/IO/all.T index 94d75f0989..e15c84d9f8 100644 --- a/libraries/base/tests/IO/all.T +++ b/libraries/base/tests/IO/all.T @@ -121,8 +121,7 @@ test('concio002', reqlib('process'), compile_and_run, ['']) test('T2122', extra_clean(['T2122-test']), compile_and_run, ['']) test('T3307', - [when(msys(), expect_fail), # Doesn't work on MSYS; see #5599 - extra_clean(['chinese-file-小说', 'chinese-name'])], + [extra_clean(['chinese-file-小说', 'chinese-name'])], run_command, ['$MAKE -s --no-print-directory T3307-test']) test('T4855', normal, compile_and_run, ['']) @@ -148,8 +147,7 @@ test('encoding003', normal, compile_and_run, ['']) test('encoding004', normal, compile_and_run, ['']) test('environment001', - [when(msys(), expect_fail), # Doesn't work on MSYS; see #5599 - extra_clean(['environment001'])], + [extra_clean(['environment001'])], run_command, ['$MAKE -s --no-print-directory environment001-test']) diff --git a/libraries/base/tests/T9111.hs b/libraries/base/tests/T9111.hs new file mode 100644 index 0000000000..b2d1716ccd --- /dev/null +++ b/libraries/base/tests/T9111.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE DataKinds #-} + +module T9111 where + +import Data.Typeable + +a = typeRep (Proxy :: Proxy 'True) +b = typeRep (Proxy :: Proxy Typeable) +c = typeRep (Proxy :: Proxy (~)) +d = typeRep (Proxy :: Proxy 'Left) diff --git a/libraries/base/tests/all.T b/libraries/base/tests/all.T index d4a6c0511b..12a241085a 100644 --- a/libraries/base/tests/all.T +++ b/libraries/base/tests/all.T @@ -114,7 +114,8 @@ test('weak001', normal, compile_and_run, ['']) # cat: write error: Permission denied # Seems to be a known problem, e.g. # http://mingw-users.1079350.n2.nabble.com/Bug-re-Unicode-on-the-console-td3121717.html -test('T4006', when(msys(), expect_fail), compile_and_run, ['']) +# May 2014: seems to work on msys2 +test('T4006', normal, compile_and_run, ['']) test('T5943', normal, compile_and_run, ['']) test('T5962', normal, compile_and_run, ['']) @@ -156,10 +157,14 @@ test('topHandler03', test('T8766', - [ stats_num_field('bytes allocated', (16828144, 5)), + [ stats_num_field('bytes allocated', + [ (wordsize(64), 16828144, 5) # with GHC-7.6.3: 83937384 (but faster execution than the next line) # before: 58771216 (without call-arity-analysis) # expected value: 16828144 (2014-01-14) - only_ways(['normal'])], + , (wordsize(32), 8433644, 5) ]) + , only_ways(['normal'])], compile_and_run, ['-O']) + +test('T9111', normal, compile, ['']) |