Wolfgang Jeltsch pushed to branch wip/jeltsch/text-read-uncovering at Glasgow Haskell Compiler / GHC Commits: 3b2f20b2 by Wolfgang Jeltsch at 2026-04-14T00:27:06+03:00 Move I/O-related `Read` instances into `base` - - - - - 8c3476f5 by Wolfgang Jeltsch at 2026-04-14T00:27:19+03:00 Move most of the `Numeric` implementation into `base` The `showHex` operation and the `showIntAtBase` operation, which underlies it, are kept in `GHC.Internal.Numeric`, because `showHex` is used in a few places in `ghc-internal`; everything else is moved. - - - - - f0ffc4b4 by Wolfgang Jeltsch at 2026-04-14T00:27:19+03:00 Move the instance `Read ByteOrder` into `base` - - - - - edace2a9 by Wolfgang Jeltsch at 2026-04-14T00:27:19+03:00 Move the implementation of version parsing into `base` - - - - - 4f44d8ee by Wolfgang Jeltsch at 2026-04-14T00:27:19+03:00 Move the implementation of `readConstr` into `base` - - - - - 21 changed files: - libraries/base/src/Data/Data.hs - libraries/base/src/Data/Version.hs - libraries/base/src/GHC/ByteOrder.hs - libraries/base/src/Numeric.hs - libraries/base/src/System/IO.hs - libraries/base/src/Text/Printf.hs - libraries/ghc-internal/src/GHC/Internal/Data/Data.hs - libraries/ghc-internal/src/GHC/Internal/Data/Version.hs - libraries/ghc-internal/src/GHC/Internal/IO/Device.hs - libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs - libraries/ghc-internal/src/GHC/Internal/IO/IOMode.hs - libraries/ghc-internal/src/GHC/Internal/Numeric.hs - libraries/ghc-internal/src/GHC/Internal/Read.hs - testsuite/tests/interface-stability/base-exports.stdout - testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs - testsuite/tests/interface-stability/base-exports.stdout-mingw32 - testsuite/tests/interface-stability/base-exports.stdout-ws-32 - testsuite/tests/plugins/plugins09.stdout - testsuite/tests/plugins/plugins10.stdout - testsuite/tests/plugins/plugins11.stdout - testsuite/tests/plugins/static-plugins.stdout Changes: ===================================== libraries/base/src/Data/Data.hs ===================================== @@ -99,3 +99,38 @@ module Data.Data ( import GHC.Internal.Data.Data import Data.Typeable + +import GHC.Real (toRational) +import GHC.Float (Double) +import Data.Eq ((==)) +import Data.Function ((.)) +import Data.Maybe (Maybe (Nothing, Just)) +import Data.List (filter) +import Data.String (String) +import Text.Read (Read, reads) + +-- | Lookup a constructor via a string +readConstr :: DataType -> String -> Maybe Constr +readConstr dt str = + case dataTypeRep dt of + AlgRep cons -> idx cons + IntRep -> mkReadCon (\i -> (mkPrimCon dt str (IntConstr i))) + FloatRep -> mkReadCon ffloat + CharRep -> mkReadCon (\c -> (mkPrimCon dt str (CharConstr c))) + NoRep -> Nothing + where + + -- Read a value and build a constructor + mkReadCon :: Read t => (t -> Constr) -> Maybe Constr + mkReadCon f = case (reads str) of + [(t,"")] -> Just (f t) + _ -> Nothing + + -- Traverse list of algebraic datatype constructors + idx :: [Constr] -> Maybe Constr + idx cons = case filter ((==) str . showConstr) cons of + [] -> Nothing + hd : _ -> Just hd + + ffloat :: Double -> Constr + ffloat = mkPrimCon dt str . FloatConstr . toRational ===================================== libraries/base/src/Data/Version.hs ===================================== @@ -1,5 +1,7 @@ {-# LANGUAGE Safe #-} +{-# LANGUAGE StandaloneDeriving #-} + -- | -- Module : Data.Version -- Copyright : (c) The University of Glasgow 2004 @@ -33,3 +35,25 @@ module Data.Version ( ) where import GHC.Internal.Data.Version + +import Control.Applicative (pure, (*>)) +import Data.Functor (fmap) +import Data.Char (isDigit, isAlphaNum) +import Text.ParserCombinators.ReadP (ReadP, char, munch1, sepBy1, many) +import Text.Read (Read, read) + +{-NOTE: + The following instance is technically an orphan, but practically it is not, + since ordinary users should not use @ghc-internal@ directly and thus get + 'Version' only through this module. +-} + +-- | @since base-2.01 +deriving instance Read Version + +-- | A parser for versions in the format produced by 'showVersion'. +-- +parseVersion :: ReadP Version +parseVersion = do branch <- sepBy1 (fmap read (munch1 isDigit)) (char '.') + tags <- many (char '-' *> munch1 isAlphaNum) + pure Version{versionBranch=branch, versionTags=tags} ===================================== libraries/base/src/GHC/ByteOrder.hs ===================================== @@ -1,5 +1,7 @@ {-# LANGUAGE Safe #-} +{-# LANGUAGE StandaloneDeriving #-} + -- | -- -- Module : GHC.ByteOrder @@ -19,4 +21,15 @@ module GHC.ByteOrder targetByteOrder ) where -import GHC.Internal.ByteOrder \ No newline at end of file +import GHC.Internal.ByteOrder + +import Text.Read + +{-NOTE: + The following instance is technically an orphan, but practically it is not, + since ordinary users should not use @ghc-internal@ directly and thus get + 'ByteOrder' only through this module. +-} + +-- | @since base-4.11.0.0 +deriving instance Read ByteOrder ===================================== libraries/base/src/Numeric.hs ===================================== @@ -1,4 +1,6 @@ -{-# LANGUAGE Safe #-} +{-# LANGUAGE Trustworthy #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE ImportQualifiedPost #-} -- | -- @@ -48,3 +50,279 @@ module Numeric ) where import GHC.Internal.Numeric + +import GHC.Types (Char (C#)) +import GHC.Err (error, errorWithoutStackTrace) +import GHC.Base (unsafeChr) +import GHC.Num (Num, (+), (-), (*)) +import GHC.Real + ( + Integral, + Real, + RealFrac, + fromIntegral, + fromRational, + quotRem, + showSigned + ) +import GHC.Float + ( + Floating (..), + RealFloat, + Float, + Double, + isNegativeZero, + isInfinite, + isNaN, + fromRat, + floatToDigits, + FFFormat (FFExponent, FFFixed, FFGeneric), + formatRealFloat, + formatRealFloatAlt, + showFloat + ) +import GHC.Read (lexDigits) +import Control.Monad (return) +import Data.Eq (Eq, (==)) +import Data.Ord ((<)) +import Data.Function (($), (.)) +import Data.Bool (Bool (False, True), otherwise, (||), (&&)) +import Data.Maybe (Maybe) +import Data.List ((++)) +import Data.Char (ord, intToDigit) +import Data.Int (Int) +import Text.ParserCombinators.ReadP (ReadP, pfail, readP_to_S) +import Text.Read (ReadS, readParen, lex) +import Text.Read.Lex qualified as L + ( + Lexeme (Number), + lex, + numberToRational, + readIntP, + readBinP, + readOctP, + readDecP, + readHexP + ) +import Text.Show (ShowS, show, showString) + +-- $setup +-- >>> import Prelude + +-- ----------------------------------------------------------------------------- +-- Reading + +-- | Reads an /unsigned/ integral value in an arbitrary base. +readInt :: Num a + => a -- ^ the base + -> (Char -> Bool) -- ^ a predicate distinguishing valid digits in this base + -> (Char -> Int) -- ^ a function converting a valid digit character to an 'Int' + -> ReadS a +readInt base isDigit valDigit = readP_to_S (L.readIntP base isDigit valDigit) + +-- | Read an unsigned number in binary notation. +-- +-- >>> readBin "10011" +-- [(19,"")] +readBin :: (Eq a, Num a) => ReadS a +readBin = readP_to_S L.readBinP + +-- | Read an unsigned number in octal notation. +-- +-- >>> readOct "0644" +-- [(420,"")] +readOct :: (Eq a, Num a) => ReadS a +readOct = readP_to_S L.readOctP + +-- | Read an unsigned number in decimal notation. +-- +-- >>> readDec "0644" +-- [(644,"")] +readDec :: (Eq a, Num a) => ReadS a +readDec = readP_to_S L.readDecP + +-- | Read an unsigned number in hexadecimal notation. +-- Both upper or lower case letters are allowed. +-- +-- >>> readHex "deadbeef" +-- [(3735928559,"")] +readHex :: (Eq a, Num a) => ReadS a +readHex = readP_to_S L.readHexP + +-- | Reads an /unsigned/ 'RealFrac' value, +-- expressed in decimal scientific notation. +-- +-- Note that this function takes time linear in the magnitude of its input +-- which can scale exponentially with input size (e.g. @"1e100000000"@ is a +-- very large number while having a very small textual form). +-- For this reason, users should take care to avoid using this function on +-- untrusted input. Users needing to parse floating point values +-- (e.g. 'Float') are encouraged to instead use 'read', which does +-- not suffer from this issue. +readFloat :: RealFrac a => ReadS a +readFloat = readP_to_S readFloatP + +readFloatP :: RealFrac a => ReadP a +readFloatP = + do tok <- L.lex + case tok of + L.Number n -> return $ fromRational $ L.numberToRational n + _ -> pfail + +-- It's turgid to have readSigned work using list comprehensions, +-- but it's specified as a ReadS to ReadS transformer +-- With a bit of luck no one will use it. + +-- | Reads a /signed/ 'Real' value, given a reader for an unsigned value. +readSigned :: (Real a) => ReadS a -> ReadS a +readSigned readPos = readParen False read' + where read' r = read'' r ++ + (do + ("-",s) <- lex r + (x,t) <- read'' s + return (-x,t)) + read'' r = do + (str,s) <- lex r + (n,"") <- readPos str + return (n,s) + +-- ----------------------------------------------------------------------------- +-- Showing + +-- | Show /non-negative/ 'Integral' numbers in base 10. +showInt :: Integral a => a -> ShowS +showInt n0 cs0 + | n0 < 0 = errorWithoutStackTrace "GHC.Internal.Numeric.showInt: can't show negative numbers" + | otherwise = go n0 cs0 + where + go n cs + | n < 10 = case unsafeChr (ord '0' + fromIntegral n) of + c@(C# _) -> c:cs + | otherwise = case unsafeChr (ord '0' + fromIntegral r) of + c@(C# _) -> go q (c:cs) + where + (q,r) = n `quotRem` 10 + +-- Controlling the format and precision of floats. The code that +-- implements the formatting itself is in @PrelNum@ to avoid +-- mutual module deps. + +{-# SPECIALIZE showEFloat :: + Maybe Int -> Float -> ShowS #-} +{-# SPECIALIZE showEFloat :: + Maybe Int -> Double -> ShowS #-} +{-# SPECIALIZE showFFloat :: + Maybe Int -> Float -> ShowS #-} +{-# SPECIALIZE showFFloat :: + Maybe Int -> Double -> ShowS #-} +{-# SPECIALIZE showGFloat :: + Maybe Int -> Float -> ShowS #-} +{-# SPECIALIZE showGFloat :: + Maybe Int -> Double -> ShowS #-} + +-- | Show a signed 'RealFloat' value +-- using scientific (exponential) notation (e.g. @2.45e2@, @1.5e-3@). +-- +-- In the call @'showEFloat' digs val@, if @digs@ is 'Nothing', +-- the value is shown to full precision; if @digs@ is @'Just' d@, +-- then at most @d@ digits after the decimal point are shown. +showEFloat :: (RealFloat a) => Maybe Int -> a -> ShowS + +-- | Show a signed 'RealFloat' value +-- using standard decimal notation (e.g. @245000@, @0.0015@). +-- +-- In the call @'showFFloat' digs val@, if @digs@ is 'Nothing', +-- the value is shown to full precision; if @digs@ is @'Just' d@, +-- then at most @d@ digits after the decimal point are shown. +showFFloat :: (RealFloat a) => Maybe Int -> a -> ShowS + +-- | Show a signed 'RealFloat' value +-- using standard decimal notation for arguments whose absolute value lies +-- between @0.1@ and @9,999,999@, and scientific notation otherwise. +-- +-- In the call @'showGFloat' digs val@, if @digs@ is 'Nothing', +-- the value is shown to full precision; if @digs@ is @'Just' d@, +-- then at most @d@ digits after the decimal point are shown. +showGFloat :: (RealFloat a) => Maybe Int -> a -> ShowS + +showEFloat d x = showString (formatRealFloat FFExponent d x) +showFFloat d x = showString (formatRealFloat FFFixed d x) +showGFloat d x = showString (formatRealFloat FFGeneric d x) + +-- | Show a signed 'RealFloat' value +-- using standard decimal notation (e.g. @245000@, @0.0015@). +-- +-- This behaves as 'showFFloat', except that a decimal point +-- is always guaranteed, even if not needed. +-- +-- @since base-4.7.0.0 +showFFloatAlt :: (RealFloat a) => Maybe Int -> a -> ShowS + +-- | Show a signed 'RealFloat' value +-- using standard decimal notation for arguments whose absolute value lies +-- between @0.1@ and @9,999,999@, and scientific notation otherwise. +-- +-- This behaves as 'showFFloat', except that a decimal point +-- is always guaranteed, even if not needed. +-- +-- @since base-4.7.0.0 +showGFloatAlt :: (RealFloat a) => Maybe Int -> a -> ShowS + +showFFloatAlt d x = showString (formatRealFloatAlt FFFixed d True x) +showGFloatAlt d x = showString (formatRealFloatAlt FFGeneric d True x) + +{- | Show a floating-point value in the hexadecimal format, +similar to the @%a@ specifier in C's printf. + + >>> showHFloat (212.21 :: Double) "" + "0x1.a86b851eb851fp7" + >>> showHFloat (-12.76 :: Float) "" + "-0x1.9851ecp3" + >>> showHFloat (-0 :: Double) "" + "-0x0p+0" + +@since base-4.11.0.0 +-} +showHFloat :: RealFloat a => a -> ShowS +showHFloat = showString . fmt + where + fmt x + | isNaN x = "NaN" + | isInfinite x = (if x < 0 then "-" else "") ++ "Infinity" + | x < 0 || isNegativeZero x = '-' : cvt (-x) + | otherwise = cvt x + + cvt x + | x == 0 = "0x0p+0" + | otherwise = + case floatToDigits 2 x of + r@([], _) -> error $ "Impossible happened: showHFloat: " ++ show r + (d:ds, e) -> "0x" ++ show d ++ frac ds ++ "p" ++ show (e-1) + + -- Given binary digits, convert them to hex in blocks of 4 + -- Special case: If all 0's, just drop it. + frac digits + | allZ digits = "" + | otherwise = "." ++ hex digits + where + hex ds = + case ds of + [] -> "" + [a] -> hexDigit a 0 0 0 "" + [a,b] -> hexDigit a b 0 0 "" + [a,b,c] -> hexDigit a b c 0 "" + a : b : c : d : r -> hexDigit a b c d (hex r) + + hexDigit a b c d = showHex (8*a + 4*b + 2*c + d) + + allZ xs = case xs of + x : more -> x == 0 && allZ more + [] -> True + +-- | Show /non-negative/ 'Integral' numbers in base 8. +showOct :: Integral a => a -> ShowS +showOct = showIntAtBase 8 intToDigit + +-- | Show /non-negative/ 'Integral' numbers in base 2. +showBin :: Integral a => a -> ShowS +showBin = showIntAtBase 2 intToDigit ===================================== libraries/base/src/System/IO.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP #-} +{-# LANGUAGE StandaloneDeriving #-} -- | -- @@ -895,3 +896,24 @@ rw_flags = output_flags .|. o_RDWR -- output -- > input^D -- output + +{-NOTE: + The following instances are technically orphans, but practically they are + not, since ordinary users should not use @ghc-internal@ directly and thus + get the instantiated types only through this module. +-} + +-- | @since base-4.2.0.0 +deriving instance Read IOMode + +-- | @since base-4.2.0.0 +deriving instance Read BufferMode + +-- | @since base-4.2.0.0 +deriving instance Read SeekMode + +-- | @since base-4.3.0.0 +deriving instance Read Newline + +-- | @since base-4.3.0.0 +deriving instance Read NewlineMode ===================================== libraries/base/src/Text/Printf.hs ===================================== @@ -97,8 +97,8 @@ import Data.Char import GHC.Internal.Int import GHC.Internal.Data.List (stripPrefix) import GHC.Internal.Word -import GHC.Internal.Numeric import GHC.Internal.Numeric.Natural +import Numeric import System.IO -- $setup ===================================== libraries/ghc-internal/src/GHC/Internal/Data/Data.hs ===================================== @@ -61,6 +61,7 @@ module GHC.Internal.Data.Data ( mkIntType, mkFloatType, mkCharType, + mkPrimCon, mkNoRepType, -- ** Observers dataTypeName, @@ -94,7 +95,6 @@ module GHC.Internal.Data.Data ( constrIndex, -- ** From strings to constructors and vice versa: all data types showConstr, - readConstr, -- * Convenience functions: take type constructors apart tyconUQname, @@ -126,10 +126,8 @@ import GHC.Internal.Base ( import GHC.Internal.Err (errorWithoutStackTrace) import GHC.Internal.List import GHC.Internal.Num -import GHC.Internal.Read import GHC.Internal.Show import GHC.Internal.Tuple (Solo (..)) -import GHC.Internal.Text.Read( reads ) import GHC.Internal.Types ( Bool(..), Char, Coercible, Float, Double, Type, type (~), type (~~), ) @@ -688,32 +686,6 @@ showConstr :: Constr -> String showConstr = constring --- | Lookup a constructor via a string -readConstr :: DataType -> String -> Maybe Constr -readConstr dt str = - case dataTypeRep dt of - AlgRep cons -> idx cons - IntRep -> mkReadCon (\i -> (mkPrimCon dt str (IntConstr i))) - FloatRep -> mkReadCon ffloat - CharRep -> mkReadCon (\c -> (mkPrimCon dt str (CharConstr c))) - NoRep -> Nothing - where - - -- Read a value and build a constructor - mkReadCon :: Read t => (t -> Constr) -> Maybe Constr - mkReadCon f = case (reads str) of - [(t,"")] -> Just (f t) - _ -> Nothing - - -- Traverse list of algebraic datatype constructors - idx :: [Constr] -> Maybe Constr - idx cons = case filter ((==) str . showConstr) cons of - [] -> Nothing - hd : _ -> Just hd - - ffloat :: Double -> Constr - ffloat = mkPrimCon dt str . FloatConstr . toRational - ------------------------------------------------------------------------------ -- -- Convenience functions: algebraic data types ===================================== libraries/ghc-internal/src/GHC/Internal/Data/Version.hs ===================================== @@ -10,7 +10,7 @@ -- -- Maintainer : libraries@haskell.org -- Stability : stable --- Portability : non-portable (local universal quantification in ReadP) +-- Portability : non-portable -- -- A general library for representation and manipulation of versions. -- @@ -31,23 +31,17 @@ module GHC.Internal.Data.Version ( -- * The @Version@ type Version(..), -- * A concrete representation of @Version@ - showVersion, parseVersion, + showVersion, -- * Constructor function makeVersion ) where -import GHC.Internal.Classes ( Eq(..), (&&) ) -import GHC.Internal.Data.Functor ( Functor(..) ) +import GHC.Internal.Classes ( Eq ((==)), (&&) ) import GHC.Internal.Int ( Int ) import GHC.Internal.Data.List ( map, sort, concat, concatMap, intersperse, (++) ) import GHC.Internal.Data.Ord import GHC.Internal.Data.String ( String ) -import GHC.Internal.Base ( Applicative(..) ) -import GHC.Internal.Unicode ( isDigit, isAlphaNum ) -import GHC.Internal.Read import GHC.Internal.Show -import GHC.Internal.Text.ParserCombinators.ReadP -import GHC.Internal.Text.Read ( read ) {- | A 'Version' represents the version of a software entity. @@ -69,8 +63,8 @@ operations are the right thing for every 'Version'. Similarly, concrete representations of versions may differ. One possible concrete representation is provided (see 'showVersion' and -'parseVersion'), but depending on the application a different concrete -representation may be more appropriate. +'Data.Version.parseVersion'), but depending on the application a +different concrete representation may be more appropriate. -} data Version = Version { versionBranch :: [Int], @@ -92,8 +86,7 @@ data Version = -- The interpretation of the list of tags is entirely dependent -- on the entity that this version applies to. } - deriving ( Read -- ^ @since base-2.01 - , Show -- ^ @since base-2.01 + deriving ( Show -- ^ @since base-2.01 ) {-# DEPRECATED versionTags "See GHC ticket #2496" #-} -- TODO. Remove all references to versionTags in GHC 8.0 release. @@ -120,13 +113,6 @@ showVersion (Version branch tags) = concat (intersperse "." (map show branch)) ++ concatMap ('-':) tags --- | A parser for versions in the format produced by 'showVersion'. --- -parseVersion :: ReadP Version -parseVersion = do branch <- sepBy1 (fmap read (munch1 isDigit)) (char '.') - tags <- many (char '-' *> munch1 isAlphaNum) - pure Version{versionBranch=branch, versionTags=tags} - -- | Construct tag-less 'Version' -- -- @since base-4.8.0.0 ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Device.hs ===================================== @@ -34,7 +34,6 @@ import GHC.Internal.Types ( Bool(..), Int ) import GHC.Internal.Word import GHC.Internal.Arr import GHC.Internal.Enum -import GHC.Internal.Read import GHC.Internal.Show import GHC.Internal.Ptr import GHC.Internal.Num @@ -182,7 +181,6 @@ data SeekMode , Ord -- ^ @since base-4.2.0.0 , Ix -- ^ @since base-4.2.0.0 , Enum -- ^ @since base-4.2.0.0 - , Read -- ^ @since base-4.2.0.0 , Show -- ^ @since base-4.2.0.0 ) ===================================== libraries/ghc-internal/src/GHC/Internal/IO/Handle/Types.hs ===================================== @@ -50,7 +50,6 @@ import GHC.Internal.IO.BufferedIO import GHC.Internal.IO.Encoding.Types import GHC.Internal.IORef import GHC.Internal.Show -import GHC.Internal.Read import GHC.Internal.Types (Bool(..), Int) import GHC.Internal.Word import GHC.Internal.IO.Device @@ -273,7 +272,6 @@ data BufferMode -- is 'Just' @n@ and is otherwise implementation-dependent. deriving ( Eq -- ^ @since base-4.2.0.0 , Ord -- ^ @since base-4.2.0.0 - , Read -- ^ @since base-4.2.0.0 , Show -- ^ @since base-4.2.0.0 ) @@ -379,7 +377,6 @@ data Newline = LF -- ^ @\'\\n\'@ | CRLF -- ^ @\'\\r\\n\'@ deriving ( Eq -- ^ @since base-4.2.0.0 , Ord -- ^ @since base-4.3.0.0 - , Read -- ^ @since base-4.3.0.0 , Show -- ^ @since base-4.3.0.0 ) @@ -396,7 +393,6 @@ data NewlineMode } deriving ( Eq -- ^ @since base-4.2.0.0 , Ord -- ^ @since base-4.3.0.0 - , Read -- ^ @since base-4.3.0.0 , Show -- ^ @since base-4.3.0.0 ) ===================================== libraries/ghc-internal/src/GHC/Internal/IO/IOMode.hs ===================================== @@ -20,7 +20,6 @@ module GHC.Internal.IO.IOMode (IOMode(..)) where import GHC.Internal.Classes (Eq, Ord) import GHC.Internal.Show -import GHC.Internal.Read import GHC.Internal.Arr import GHC.Internal.Enum @@ -30,7 +29,6 @@ data IOMode = ReadMode | WriteMode | AppendMode | ReadWriteMode , Ord -- ^ @since base-4.2.0.0 , Ix -- ^ @since base-4.2.0.0 , Enum -- ^ @since base-4.2.0.0 - , Read -- ^ @since base-4.2.0.0 , Show -- ^ @since base-4.2.0.0 ) ===================================== libraries/ghc-internal/src/GHC/Internal/Numeric.hs ===================================== @@ -1,5 +1,4 @@ {-# LANGUAGE Trustworthy #-} -{-# LANGUAGE NoImplicitPrelude, MagicHash #-} ----------------------------------------------------------------------------- -- | @@ -16,279 +15,16 @@ -- ----------------------------------------------------------------------------- -module GHC.Internal.Numeric ( +module GHC.Internal.Numeric (showIntAtBase, showHex) where - -- * Showing - - showSigned, - - showIntAtBase, - showInt, - showBin, - showHex, - showOct, - - showEFloat, - showFFloat, - showGFloat, - showFFloatAlt, - showGFloatAlt, - showFloat, - showHFloat, - - floatToDigits, - - -- * Reading - - -- | /NB:/ 'readInt' is the \'dual\' of 'showIntAtBase', - -- and 'readDec' is the \`dual\' of 'showInt'. - -- The inconsistent naming is a historical accident. - - readSigned, - - readInt, - readBin, - readDec, - readOct, - readHex, - - readFloat, - - lexDigits, - - -- * Miscellaneous - - fromRat, - Floating(..) - - ) where - -import GHC.Internal.Base (ord, otherwise, return, unsafeChr, ($), (.), (++)) -import GHC.Internal.Classes (Eq(..), Ord(..), (&&), (||)) -import GHC.Internal.Err (error, errorWithoutStackTrace) -import GHC.Internal.Maybe (Maybe(..)) import GHC.Internal.Prim (seq) -import GHC.Internal.Read -import GHC.Internal.Real -import GHC.Internal.Float -import GHC.Internal.Num -import GHC.Internal.Show -import GHC.Internal.Text.ParserCombinators.ReadP( ReadP, readP_to_S, pfail ) -import qualified GHC.Internal.Text.Read.Lex as L -import GHC.Internal.Types (Bool(..), Char(..), Int) - --- $setup --- >>> import Prelude - --- ----------------------------------------------------------------------------- --- Reading - --- | Reads an /unsigned/ integral value in an arbitrary base. -readInt :: Num a - => a -- ^ the base - -> (Char -> Bool) -- ^ a predicate distinguishing valid digits in this base - -> (Char -> Int) -- ^ a function converting a valid digit character to an 'Int' - -> ReadS a -readInt base isDigit valDigit = readP_to_S (L.readIntP base isDigit valDigit) - --- | Read an unsigned number in binary notation. --- --- >>> readBin "10011" --- [(19,"")] -readBin :: (Eq a, Num a) => ReadS a -readBin = readP_to_S L.readBinP - --- | Read an unsigned number in octal notation. --- --- >>> readOct "0644" --- [(420,"")] -readOct :: (Eq a, Num a) => ReadS a -readOct = readP_to_S L.readOctP - --- | Read an unsigned number in decimal notation. --- --- >>> readDec "0644" --- [(644,"")] -readDec :: (Eq a, Num a) => ReadS a -readDec = readP_to_S L.readDecP - --- | Read an unsigned number in hexadecimal notation. --- Both upper or lower case letters are allowed. --- --- >>> readHex "deadbeef" --- [(3735928559,"")] -readHex :: (Eq a, Num a) => ReadS a -readHex = readP_to_S L.readHexP - --- | Reads an /unsigned/ 'RealFrac' value, --- expressed in decimal scientific notation. --- --- Note that this function takes time linear in the magnitude of its input --- which can scale exponentially with input size (e.g. @"1e100000000"@ is a --- very large number while having a very small textual form). --- For this reason, users should take care to avoid using this function on --- untrusted input. Users needing to parse floating point values --- (e.g. 'Float') are encouraged to instead use 'read', which does --- not suffer from this issue. -readFloat :: RealFrac a => ReadS a -readFloat = readP_to_S readFloatP - -readFloatP :: RealFrac a => ReadP a -readFloatP = - do tok <- L.lex - case tok of - L.Number n -> return $ fromRational $ L.numberToRational n - _ -> pfail - --- It's turgid to have readSigned work using list comprehensions, --- but it's specified as a ReadS to ReadS transformer --- With a bit of luck no one will use it. - --- | Reads a /signed/ 'Real' value, given a reader for an unsigned value. -readSigned :: (Real a) => ReadS a -> ReadS a -readSigned readPos = readParen False read' - where read' r = read'' r ++ - (do - ("-",s) <- lex r - (x,t) <- read'' s - return (-x,t)) - read'' r = do - (str,s) <- lex r - (n,"") <- readPos str - return (n,s) - --- ----------------------------------------------------------------------------- --- Showing - --- | Show /non-negative/ 'Integral' numbers in base 10. -showInt :: Integral a => a -> ShowS -showInt n0 cs0 - | n0 < 0 = errorWithoutStackTrace "GHC.Internal.Numeric.showInt: can't show negative numbers" - | otherwise = go n0 cs0 - where - go n cs - | n < 10 = case unsafeChr (ord '0' + fromIntegral n) of - c@(C# _) -> c:cs - | otherwise = case unsafeChr (ord '0' + fromIntegral r) of - c@(C# _) -> go q (c:cs) - where - (q,r) = n `quotRem` 10 - --- Controlling the format and precision of floats. The code that --- implements the formatting itself is in @PrelNum@ to avoid --- mutual module deps. - -{-# SPECIALIZE showEFloat :: - Maybe Int -> Float -> ShowS #-} -{-# SPECIALIZE showEFloat :: - Maybe Int -> Double -> ShowS #-} -{-# SPECIALIZE showFFloat :: - Maybe Int -> Float -> ShowS #-} -{-# SPECIALIZE showFFloat :: - Maybe Int -> Double -> ShowS #-} -{-# SPECIALIZE showGFloat :: - Maybe Int -> Float -> ShowS #-} -{-# SPECIALIZE showGFloat :: - Maybe Int -> Double -> ShowS #-} - --- | Show a signed 'RealFloat' value --- using scientific (exponential) notation (e.g. @2.45e2@, @1.5e-3@). --- --- In the call @'showEFloat' digs val@, if @digs@ is 'Nothing', --- the value is shown to full precision; if @digs@ is @'Just' d@, --- then at most @d@ digits after the decimal point are shown. -showEFloat :: (RealFloat a) => Maybe Int -> a -> ShowS - --- | Show a signed 'RealFloat' value --- using standard decimal notation (e.g. @245000@, @0.0015@). --- --- In the call @'showFFloat' digs val@, if @digs@ is 'Nothing', --- the value is shown to full precision; if @digs@ is @'Just' d@, --- then at most @d@ digits after the decimal point are shown. -showFFloat :: (RealFloat a) => Maybe Int -> a -> ShowS - --- | Show a signed 'RealFloat' value --- using standard decimal notation for arguments whose absolute value lies --- between @0.1@ and @9,999,999@, and scientific notation otherwise. --- --- In the call @'showGFloat' digs val@, if @digs@ is 'Nothing', --- the value is shown to full precision; if @digs@ is @'Just' d@, --- then at most @d@ digits after the decimal point are shown. -showGFloat :: (RealFloat a) => Maybe Int -> a -> ShowS - -showEFloat d x = showString (formatRealFloat FFExponent d x) -showFFloat d x = showString (formatRealFloat FFFixed d x) -showGFloat d x = showString (formatRealFloat FFGeneric d x) - --- | Show a signed 'RealFloat' value --- using standard decimal notation (e.g. @245000@, @0.0015@). --- --- This behaves as 'showFFloat', except that a decimal point --- is always guaranteed, even if not needed. --- --- @since base-4.7.0.0 -showFFloatAlt :: (RealFloat a) => Maybe Int -> a -> ShowS - --- | Show a signed 'RealFloat' value --- using standard decimal notation for arguments whose absolute value lies --- between @0.1@ and @9,999,999@, and scientific notation otherwise. --- --- This behaves as 'showFFloat', except that a decimal point --- is always guaranteed, even if not needed. --- --- @since base-4.7.0.0 -showGFloatAlt :: (RealFloat a) => Maybe Int -> a -> ShowS - -showFFloatAlt d x = showString (formatRealFloatAlt FFFixed d True x) -showGFloatAlt d x = showString (formatRealFloatAlt FFGeneric d True x) - -{- | Show a floating-point value in the hexadecimal format, -similar to the @%a@ specifier in C's printf. - - >>> showHFloat (212.21 :: Double) "" - "0x1.a86b851eb851fp7" - >>> showHFloat (-12.76 :: Float) "" - "-0x1.9851ecp3" - >>> showHFloat (-0 :: Double) "" - "-0x0p+0" - -@since base-4.11.0.0 --} -showHFloat :: RealFloat a => a -> ShowS -showHFloat = showString . fmt - where - fmt x - | isNaN x = "NaN" - | isInfinite x = (if x < 0 then "-" else "") ++ "Infinity" - | x < 0 || isNegativeZero x = '-' : cvt (-x) - | otherwise = cvt x - - cvt x - | x == 0 = "0x0p+0" - | otherwise = - case floatToDigits 2 x of - r@([], _) -> error $ "Impossible happened: showHFloat: " ++ show r - (d:ds, e) -> "0x" ++ show d ++ frac ds ++ "p" ++ show (e-1) - - -- Given binary digits, convert them to hex in blocks of 4 - -- Special case: If all 0's, just drop it. - frac digits - | allZ digits = "" - | otherwise = "." ++ hex digits - where - hex ds = - case ds of - [] -> "" - [a] -> hexDigit a 0 0 0 "" - [a,b] -> hexDigit a b 0 0 "" - [a,b,c] -> hexDigit a b c 0 "" - a : b : c : d : r -> hexDigit a b c d (hex r) - - hexDigit a b c d = showHex (8*a + 4*b + 2*c + d) - - allZ xs = case xs of - x : more -> x == 0 && allZ more - [] -> True +import GHC.Internal.Types (Char, Int) +import GHC.Internal.Classes ((<), (<=)) +import GHC.Internal.Err (errorWithoutStackTrace) +import GHC.Internal.Base (($), otherwise) +import GHC.Internal.List ((++)) +import GHC.Internal.Real (Integral, toInteger, fromIntegral, quotRem) +import GHC.Internal.Show (ShowS, show, intToDigit) -- --------------------------------------------------------------------------- -- Integer printing functions @@ -312,11 +48,3 @@ showIntAtBase base toChr n0 r0 -- | Show /non-negative/ 'Integral' numbers in base 16. showHex :: Integral a => a -> ShowS showHex = showIntAtBase 16 intToDigit - --- | Show /non-negative/ 'Integral' numbers in base 8. -showOct :: Integral a => a -> ShowS -showOct = showIntAtBase 8 intToDigit - --- | Show /non-negative/ 'Integral' numbers in base 2. -showBin :: Integral a => a -> ShowS -showBin = showIntAtBase 2 intToDigit ===================================== libraries/ghc-internal/src/GHC/Internal/Read.hs ===================================== @@ -80,7 +80,6 @@ import GHC.Internal.Types (Bool(..), Char, Int, Ordering(..)) import GHC.Internal.Word import GHC.Internal.List (filter) import GHC.Internal.Tuple (Solo (..)) -import GHC.Internal.ByteOrder -- | @'readParen' 'True' p@ parses what @p@ parses, but surrounded with @@ -840,6 +839,3 @@ instance (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, ; return (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) }) readListPrec = readListPrecDefault readList = readListDefault - --- | @since base-4.11.0.0 -deriving instance Read ByteOrder ===================================== testsuite/tests/interface-stability/base-exports.stdout ===================================== @@ -9453,7 +9453,7 @@ module GHC.Word where uncheckedShiftRL64# :: GHC.Internal.Prim.Word64# -> GHC.Internal.Prim.Int# -> GHC.Internal.Prim.Word64# module Numeric where - -- Safety: Safe + -- Safety: Trustworthy type Floating :: * -> Constraint class GHC.Internal.Real.Fractional a => Floating a where pi :: a @@ -12430,7 +12430,6 @@ instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (GHC.Inter instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (GHC.Internal.Data.Bits.Xor a) -- Defined in ‘GHC.Internal.Data.Bits’ instance forall a b. (GHC.Internal.Ix.Ix a, GHC.Internal.Read.Read a, GHC.Internal.Read.Read b) => GHC.Internal.Read.Read (GHC.Internal.Arr.Array a b) -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Bool -- Defined in ‘GHC.Internal.Read’ -instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Char -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Read’ @@ -12497,7 +12496,7 @@ instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Data.Semi instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Data.Semigroup.Min a) -- Defined in ‘Data.Semigroup’ instance forall m. GHC.Internal.Read.Read m => GHC.Internal.Read.Read (Data.Semigroup.WrappedMonoid m) -- Defined in ‘Data.Semigroup’ instance forall k (a :: k) (b :: k). Coercible a b => GHC.Internal.Read.Read (GHC.Internal.Data.Type.Coercion.Coercion a b) -- Defined in ‘GHC.Internal.Data.Type.Coercion’ -instance GHC.Internal.Read.Read GHC.Internal.Data.Version.Version -- Defined in ‘GHC.Internal.Data.Version’ +instance [safe] GHC.Internal.Read.Read GHC.Internal.Data.Version.Version -- Defined in ‘Data.Version’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.Ptr.IntPtr -- Defined in ‘GHC.Internal.Foreign.Ptr’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.Ptr.WordPtr -- Defined in ‘GHC.Internal.Foreign.Ptr’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CBool -- Defined in ‘GHC.Internal.Foreign.C.Types’ @@ -12526,6 +12525,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance [safe] GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.ByteOrder’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 k1 (f :: k2 -> *) (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12540,16 +12540,16 @@ instance GHC.Internal.Read.Read GHC.Internal.Generics.SourceStrictness -- Define instance GHC.Internal.Read.Read GHC.Internal.Generics.SourceUnpackedness -- Defined in ‘GHC.Internal.Generics’ instance forall k (p :: k). GHC.Internal.Read.Read (GHC.Internal.Generics.U1 p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (p :: k). GHC.Internal.Read.Read (GHC.Internal.Generics.V1 p) -- Defined in ‘GHC.Internal.Generics’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Device.SeekMode -- Defined in ‘GHC.Internal.IO.Device’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.BufferMode -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.Newline -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.NewlineMode -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance GHC.Internal.Read.Read GHC.Internal.IO.IOMode.IOMode -- Defined in ‘GHC.Internal.IO.IOMode’ instance [safe] GHC.Internal.Read.Read GHC.Stats.GCDetails -- Defined in ‘GHC.Stats’ instance [safe] GHC.Internal.Read.Read GHC.Stats.RTSStats -- Defined in ‘GHC.Stats’ instance GHC.Internal.Read.Read GHC.Internal.TypeNats.SomeNat -- Defined in ‘GHC.Internal.TypeNats’ instance GHC.Internal.Read.Read GHC.Internal.TypeLits.SomeChar -- Defined in ‘GHC.Internal.TypeLits’ instance GHC.Internal.Read.Read GHC.Internal.TypeLits.SomeSymbol -- Defined in ‘GHC.Internal.TypeLits’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.BufferMode -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.IOMode.IOMode -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.Newline -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.NewlineMode -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Device.SeekMode -- Defined in ‘System.IO’ instance forall k a (b :: k). GHC.Internal.Real.Fractional a => GHC.Internal.Real.Fractional (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall a. GHC.Internal.Float.RealFloat a => GHC.Internal.Real.Fractional (Data.Complex.Complex a) -- Defined in ‘Data.Complex’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Fractional (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs ===================================== @@ -9491,7 +9491,7 @@ module GHC.Word where uncheckedShiftRL64# :: GHC.Internal.Prim.Word64# -> GHC.Internal.Prim.Int# -> GHC.Internal.Prim.Word64# module Numeric where - -- Safety: Safe + -- Safety: Trustworthy type Floating :: * -> Constraint class GHC.Internal.Real.Fractional a => Floating a where pi :: a @@ -12459,7 +12459,6 @@ instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (GHC.Inter instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (GHC.Internal.Data.Bits.Xor a) -- Defined in ‘GHC.Internal.Data.Bits’ instance forall a b. (GHC.Internal.Ix.Ix a, GHC.Internal.Read.Read a, GHC.Internal.Read.Read b) => GHC.Internal.Read.Read (GHC.Internal.Arr.Array a b) -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Bool -- Defined in ‘GHC.Internal.Read’ -instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Char -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Read’ @@ -12526,7 +12525,7 @@ instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Data.Semi instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Data.Semigroup.Min a) -- Defined in ‘Data.Semigroup’ instance forall m. GHC.Internal.Read.Read m => GHC.Internal.Read.Read (Data.Semigroup.WrappedMonoid m) -- Defined in ‘Data.Semigroup’ instance forall k (a :: k) (b :: k). Coercible a b => GHC.Internal.Read.Read (GHC.Internal.Data.Type.Coercion.Coercion a b) -- Defined in ‘GHC.Internal.Data.Type.Coercion’ -instance GHC.Internal.Read.Read GHC.Internal.Data.Version.Version -- Defined in ‘GHC.Internal.Data.Version’ +instance [safe] GHC.Internal.Read.Read GHC.Internal.Data.Version.Version -- Defined in ‘Data.Version’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.Ptr.IntPtr -- Defined in ‘GHC.Internal.Foreign.Ptr’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.Ptr.WordPtr -- Defined in ‘GHC.Internal.Foreign.Ptr’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CBool -- Defined in ‘GHC.Internal.Foreign.C.Types’ @@ -12555,6 +12554,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance [safe] GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.ByteOrder’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 k1 (f :: k2 -> *) (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12569,16 +12569,16 @@ instance GHC.Internal.Read.Read GHC.Internal.Generics.SourceStrictness -- Define instance GHC.Internal.Read.Read GHC.Internal.Generics.SourceUnpackedness -- Defined in ‘GHC.Internal.Generics’ instance forall k (p :: k). GHC.Internal.Read.Read (GHC.Internal.Generics.U1 p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (p :: k). GHC.Internal.Read.Read (GHC.Internal.Generics.V1 p) -- Defined in ‘GHC.Internal.Generics’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Device.SeekMode -- Defined in ‘GHC.Internal.IO.Device’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.BufferMode -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.Newline -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.NewlineMode -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance GHC.Internal.Read.Read GHC.Internal.IO.IOMode.IOMode -- Defined in ‘GHC.Internal.IO.IOMode’ instance [safe] GHC.Internal.Read.Read GHC.Stats.GCDetails -- Defined in ‘GHC.Stats’ instance [safe] GHC.Internal.Read.Read GHC.Stats.RTSStats -- Defined in ‘GHC.Stats’ instance GHC.Internal.Read.Read GHC.Internal.TypeNats.SomeNat -- Defined in ‘GHC.Internal.TypeNats’ instance GHC.Internal.Read.Read GHC.Internal.TypeLits.SomeChar -- Defined in ‘GHC.Internal.TypeLits’ instance GHC.Internal.Read.Read GHC.Internal.TypeLits.SomeSymbol -- Defined in ‘GHC.Internal.TypeLits’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.BufferMode -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.IOMode.IOMode -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.Newline -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.NewlineMode -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Device.SeekMode -- Defined in ‘System.IO’ instance forall k a (b :: k). GHC.Internal.Real.Fractional a => GHC.Internal.Real.Fractional (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall a. GHC.Internal.Float.RealFloat a => GHC.Internal.Real.Fractional (Data.Complex.Complex a) -- Defined in ‘Data.Complex’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Fractional (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-mingw32 ===================================== @@ -9733,7 +9733,7 @@ module GHC.Word where uncheckedShiftRL64# :: GHC.Internal.Prim.Word64# -> GHC.Internal.Prim.Int# -> GHC.Internal.Prim.Word64# module Numeric where - -- Safety: Safe + -- Safety: Trustworthy type Floating :: * -> Constraint class GHC.Internal.Real.Fractional a => Floating a where pi :: a @@ -12701,7 +12701,6 @@ instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (GHC.Inter instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (GHC.Internal.Data.Bits.Xor a) -- Defined in ‘GHC.Internal.Data.Bits’ instance forall a b. (GHC.Internal.Ix.Ix a, GHC.Internal.Read.Read a, GHC.Internal.Read.Read b) => GHC.Internal.Read.Read (GHC.Internal.Arr.Array a b) -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Bool -- Defined in ‘GHC.Internal.Read’ -instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Char -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Read’ @@ -12768,7 +12767,7 @@ instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Data.Semi instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Data.Semigroup.Min a) -- Defined in ‘Data.Semigroup’ instance forall m. GHC.Internal.Read.Read m => GHC.Internal.Read.Read (Data.Semigroup.WrappedMonoid m) -- Defined in ‘Data.Semigroup’ instance forall k (a :: k) (b :: k). Coercible a b => GHC.Internal.Read.Read (GHC.Internal.Data.Type.Coercion.Coercion a b) -- Defined in ‘GHC.Internal.Data.Type.Coercion’ -instance GHC.Internal.Read.Read GHC.Internal.Data.Version.Version -- Defined in ‘GHC.Internal.Data.Version’ +instance [safe] GHC.Internal.Read.Read GHC.Internal.Data.Version.Version -- Defined in ‘Data.Version’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.Ptr.IntPtr -- Defined in ‘GHC.Internal.Foreign.Ptr’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.Ptr.WordPtr -- Defined in ‘GHC.Internal.Foreign.Ptr’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CBool -- Defined in ‘GHC.Internal.Foreign.C.Types’ @@ -12797,6 +12796,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance [safe] GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.ByteOrder’ instance GHC.Internal.Read.Read GHC.Internal.Event.Windows.ConsoleEvent.ConsoleEvent -- Defined in ‘GHC.Internal.Event.Windows.ConsoleEvent’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12812,16 +12812,16 @@ instance GHC.Internal.Read.Read GHC.Internal.Generics.SourceStrictness -- Define instance GHC.Internal.Read.Read GHC.Internal.Generics.SourceUnpackedness -- Defined in ‘GHC.Internal.Generics’ instance forall k (p :: k). GHC.Internal.Read.Read (GHC.Internal.Generics.U1 p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (p :: k). GHC.Internal.Read.Read (GHC.Internal.Generics.V1 p) -- Defined in ‘GHC.Internal.Generics’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Device.SeekMode -- Defined in ‘GHC.Internal.IO.Device’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.BufferMode -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.Newline -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.NewlineMode -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance GHC.Internal.Read.Read GHC.Internal.IO.IOMode.IOMode -- Defined in ‘GHC.Internal.IO.IOMode’ instance [safe] GHC.Internal.Read.Read GHC.Stats.GCDetails -- Defined in ‘GHC.Stats’ instance [safe] GHC.Internal.Read.Read GHC.Stats.RTSStats -- Defined in ‘GHC.Stats’ instance GHC.Internal.Read.Read GHC.Internal.TypeNats.SomeNat -- Defined in ‘GHC.Internal.TypeNats’ instance GHC.Internal.Read.Read GHC.Internal.TypeLits.SomeChar -- Defined in ‘GHC.Internal.TypeLits’ instance GHC.Internal.Read.Read GHC.Internal.TypeLits.SomeSymbol -- Defined in ‘GHC.Internal.TypeLits’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.BufferMode -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.IOMode.IOMode -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.Newline -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.NewlineMode -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Device.SeekMode -- Defined in ‘System.IO’ instance forall k a (b :: k). GHC.Internal.Real.Fractional a => GHC.Internal.Real.Fractional (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall a. GHC.Internal.Float.RealFloat a => GHC.Internal.Real.Fractional (Data.Complex.Complex a) -- Defined in ‘Data.Complex’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Fractional (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ ===================================== testsuite/tests/interface-stability/base-exports.stdout-ws-32 ===================================== @@ -9453,7 +9453,7 @@ module GHC.Word where uncheckedShiftRL64# :: GHC.Internal.Prim.Word64# -> GHC.Internal.Prim.Int# -> GHC.Internal.Prim.Word64# module Numeric where - -- Safety: Safe + -- Safety: Trustworthy type Floating :: * -> Constraint class GHC.Internal.Real.Fractional a => Floating a where pi :: a @@ -12430,7 +12430,6 @@ instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (GHC.Inter instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (GHC.Internal.Data.Bits.Xor a) -- Defined in ‘GHC.Internal.Data.Bits’ instance forall a b. (GHC.Internal.Ix.Ix a, GHC.Internal.Read.Read a, GHC.Internal.Read.Read b) => GHC.Internal.Read.Read (GHC.Internal.Arr.Array a b) -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Bool -- Defined in ‘GHC.Internal.Read’ -instance GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Char -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Double -- Defined in ‘GHC.Internal.Read’ instance GHC.Internal.Read.Read GHC.Internal.Types.Float -- Defined in ‘GHC.Internal.Read’ @@ -12497,7 +12496,7 @@ instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Data.Semi instance forall a. GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Data.Semigroup.Min a) -- Defined in ‘Data.Semigroup’ instance forall m. GHC.Internal.Read.Read m => GHC.Internal.Read.Read (Data.Semigroup.WrappedMonoid m) -- Defined in ‘Data.Semigroup’ instance forall k (a :: k) (b :: k). Coercible a b => GHC.Internal.Read.Read (GHC.Internal.Data.Type.Coercion.Coercion a b) -- Defined in ‘GHC.Internal.Data.Type.Coercion’ -instance GHC.Internal.Read.Read GHC.Internal.Data.Version.Version -- Defined in ‘GHC.Internal.Data.Version’ +instance [safe] GHC.Internal.Read.Read GHC.Internal.Data.Version.Version -- Defined in ‘Data.Version’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.Ptr.IntPtr -- Defined in ‘GHC.Internal.Foreign.Ptr’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.Ptr.WordPtr -- Defined in ‘GHC.Internal.Foreign.Ptr’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CBool -- Defined in ‘GHC.Internal.Foreign.C.Types’ @@ -12526,6 +12525,7 @@ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CULong -- Defined i instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUSeconds -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CUShort -- Defined in ‘GHC.Internal.Foreign.C.Types’ instance GHC.Internal.Read.Read GHC.Internal.Foreign.C.Types.CWchar -- Defined in ‘GHC.Internal.Foreign.C.Types’ +instance [safe] GHC.Internal.Read.Read GHC.Internal.ByteOrder.ByteOrder -- Defined in ‘GHC.ByteOrder’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:*:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Internal.Read.Read (f p), GHC.Internal.Read.Read (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:+:) f g p) -- Defined in ‘GHC.Internal.Generics’ instance forall k2 k1 (f :: k2 -> *) (g :: k1 -> k2) (p :: k1). GHC.Internal.Read.Read (f (g p)) => GHC.Internal.Read.Read ((GHC.Internal.Generics.:.:) f g p) -- Defined in ‘GHC.Internal.Generics’ @@ -12540,16 +12540,16 @@ instance GHC.Internal.Read.Read GHC.Internal.Generics.SourceStrictness -- Define instance GHC.Internal.Read.Read GHC.Internal.Generics.SourceUnpackedness -- Defined in ‘GHC.Internal.Generics’ instance forall k (p :: k). GHC.Internal.Read.Read (GHC.Internal.Generics.U1 p) -- Defined in ‘GHC.Internal.Generics’ instance forall k (p :: k). GHC.Internal.Read.Read (GHC.Internal.Generics.V1 p) -- Defined in ‘GHC.Internal.Generics’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Device.SeekMode -- Defined in ‘GHC.Internal.IO.Device’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.BufferMode -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.Newline -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.NewlineMode -- Defined in ‘GHC.Internal.IO.Handle.Types’ -instance GHC.Internal.Read.Read GHC.Internal.IO.IOMode.IOMode -- Defined in ‘GHC.Internal.IO.IOMode’ instance [safe] GHC.Internal.Read.Read GHC.Stats.GCDetails -- Defined in ‘GHC.Stats’ instance [safe] GHC.Internal.Read.Read GHC.Stats.RTSStats -- Defined in ‘GHC.Stats’ instance GHC.Internal.Read.Read GHC.Internal.TypeNats.SomeNat -- Defined in ‘GHC.Internal.TypeNats’ instance GHC.Internal.Read.Read GHC.Internal.TypeLits.SomeChar -- Defined in ‘GHC.Internal.TypeLits’ instance GHC.Internal.Read.Read GHC.Internal.TypeLits.SomeSymbol -- Defined in ‘GHC.Internal.TypeLits’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.BufferMode -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.IOMode.IOMode -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.Newline -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Handle.Types.NewlineMode -- Defined in ‘System.IO’ +instance GHC.Internal.Read.Read GHC.Internal.IO.Device.SeekMode -- Defined in ‘System.IO’ instance forall k a (b :: k). GHC.Internal.Real.Fractional a => GHC.Internal.Real.Fractional (GHC.Internal.Data.Functor.Const.Const a b) -- Defined in ‘GHC.Internal.Data.Functor.Const’ instance forall a. GHC.Internal.Float.RealFloat a => GHC.Internal.Real.Fractional (Data.Complex.Complex a) -- Defined in ‘Data.Complex’ instance forall k (a :: k). Data.Fixed.HasResolution a => GHC.Internal.Real.Fractional (Data.Fixed.Fixed a) -- Defined in ‘Data.Fixed’ ===================================== testsuite/tests/plugins/plugins09.stdout ===================================== @@ -1,5 +1,6 @@ parsePlugin(a,b) interfacePlugin: Prelude +interfacePlugin: System.IO interfacePlugin: GHC.Internal.Base interfacePlugin: GHC.Internal.Data.NonEmpty interfacePlugin: GHC.Internal.Float ===================================== testsuite/tests/plugins/plugins10.stdout ===================================== @@ -2,6 +2,8 @@ parsePlugin() interfacePlugin: Prelude interfacePlugin: Language.Haskell.TH interfacePlugin: Language.Haskell.TH.Quote +interfacePlugin: Data.Version +interfacePlugin: System.IO interfacePlugin: GHC.Internal.Base interfacePlugin: GHC.Internal.Data.NonEmpty interfacePlugin: GHC.Internal.Float ===================================== testsuite/tests/plugins/plugins11.stdout ===================================== @@ -1,5 +1,6 @@ parsePlugin() interfacePlugin: Prelude +interfacePlugin: System.IO interfacePlugin: GHC.Internal.Base interfacePlugin: GHC.Internal.Data.NonEmpty interfacePlugin: GHC.Internal.Float ===================================== testsuite/tests/plugins/static-plugins.stdout ===================================== @@ -1,6 +1,7 @@ ==pure.0 parsePlugin() interfacePlugin: Prelude +interfacePlugin: System.IO interfacePlugin: GHC.Internal.Base interfacePlugin: GHC.Internal.Data.NonEmpty interfacePlugin: GHC.Internal.Float View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f336dac4cc4a43fc2c78b20e1303a73... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f336dac4cc4a43fc2c78b20e1303a73... You're receiving this email because of your account on gitlab.haskell.org.