Commit bc21ea0a authored by Erik de Castro Lopo's avatar Erik de Castro Lopo Committed by Erik de Castro Lopo
Browse files

GHC.Word: Move Read instances to GHC.Read

Test Plan: Validate

Reviewers: hvr, austin, bgamari

Reviewed By: hvr

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3353
parent 2fd283bf
......@@ -6,7 +6,7 @@
-- Module : Data.Word
-- Copyright : (c) The University of Glasgow 2001
-- License : BSD-style (see the file libraries/base/LICENSE)
--
--
-- Maintainer : libraries@haskell.org
-- Stability : experimental
-- Portability : portable
......@@ -31,6 +31,7 @@ module Data.Word
) where
import GHC.Word
import GHC.Read () -- Need the `Read` instance for types defined in `GHC.Word`.
{- $notes
......@@ -55,6 +56,6 @@ import GHC.Word
of the type result in a zero result. This is contrary to the
behaviour in C, which is undefined; a common interpretation is to
truncate the shift count to the width of the type, for example @1 \<\<
32 == 1@ in some C implementations.
32 == 1@ in some C implementations.
-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude, StandaloneDeriving, ScopedTypeVariables #-}
{-# LANGUAGE CPP, NoImplicitPrelude, StandaloneDeriving, ScopedTypeVariables #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
......@@ -42,6 +42,8 @@ module GHC.Read
)
where
#include "MachDeps.h"
import qualified Text.ParserCombinators.ReadP as P
import Text.ParserCombinators.ReadP
......@@ -66,6 +68,7 @@ import GHC.Float
import GHC.Show
import GHC.Base
import GHC.Arr
import GHC.Word
-- | @'readParen' 'True' p@ parses what @p@ parses, but surrounded with
......@@ -520,6 +523,26 @@ instance Read Int where
instance Read Word where
readsPrec p s = [(fromInteger x, r) | (x, r) <- readsPrec p s]
-- | @since 2.01
instance Read Word8 where
readsPrec p s = [(fromIntegral (x::Int), r) | (x, r) <- readsPrec p s]
-- | @since 2.01
instance Read Word16 where
readsPrec p s = [(fromIntegral (x::Int), r) | (x, r) <- readsPrec p s]
-- | @since 2.01
instance Read Word32 where
#if WORD_SIZE_IN_BITS < 33
readsPrec p s = [(fromInteger x, r) | (x, r) <- readsPrec p s]
#else
readsPrec p s = [(fromIntegral (x::Int), r) | (x, r) <- readsPrec p s]
#endif
-- | @since 2.01
instance Read Word64 where
readsPrec p s = [(fromInteger x, r) | (x, r) <- readsPrec p s]
-- | @since 2.01
instance Read Integer where
readPrec = readNumber convertInt
......
......@@ -51,7 +51,6 @@ import GHC.Base
import GHC.Enum
import GHC.Num
import GHC.Real
import GHC.Read
import GHC.Arr
import GHC.Show
......@@ -164,10 +163,6 @@ instance Ix Word8 where
unsafeIndex (m,_) i = fromIntegral (i - m)
inRange (m,n) i = m <= i && i <= n
-- | @since 2.01
instance Read Word8 where
readsPrec p s = [(fromIntegral (x::Int), r) | (x, r) <- readsPrec p s]
-- | @since 2.01
instance Bits Word8 where
{-# INLINE shift #-}
......@@ -352,10 +347,6 @@ instance Ix Word16 where
unsafeIndex (m,_) i = fromIntegral (i - m)
inRange (m,n) i = m <= i && i <= n
-- | @since 2.01
instance Read Word16 where
readsPrec p s = [(fromIntegral (x::Int), r) | (x, r) <- readsPrec p s]
-- | @since 2.01
instance Bits Word16 where
{-# INLINE shift #-}
......@@ -657,14 +648,6 @@ instance Ix Word32 where
unsafeIndex (m,_) i = fromIntegral (i - m)
inRange (m,n) i = m <= i && i <= n
-- | @since 2.01
instance Read Word32 where
#if WORD_SIZE_IN_BITS < 33
readsPrec p s = [(fromInteger x, r) | (x, r) <- readsPrec p s]
#else
readsPrec p s = [(fromIntegral (x::Int), r) | (x, r) <- readsPrec p s]
#endif
-- | Reverse order of bytes in 'Word32'.
--
-- @since 4.7.0.0
......@@ -979,10 +962,6 @@ instance Ix Word64 where
unsafeIndex (m,_) i = fromIntegral (i - m)
inRange (m,n) i = m <= i && i <= n
-- | @since 2.01
instance Read Word64 where
readsPrec p s = [(fromInteger x, r) | (x, r) <- readsPrec p s]
-- | Reverse order of bytes in 'Word64'.
--
-- @since 4.7.0.0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment