-{-# OPTIONS -fno-implicit-prelude #-}
+{-# OPTIONS_GHC -fno-implicit-prelude #-}
-----------------------------------------------------------------------------
-- |
-- Module : GHC.Int
#include "MachDeps.h"
+-- #hide
module GHC.Int (
Int8(..), Int16(..), Int32(..), Int64(..))
where
data Int8 = I8# Int# deriving (Eq, Ord)
-- ^ 8-bit signed integer type
-instance CCallable Int8
-instance CReturnable Int8
-
instance Show Int8 where
showsPrec p x = showsPrec p (fromIntegral x :: Int)
instance Ix Int8 where
range (m,n) = [m..n]
- unsafeIndex b@(m,_) i = fromIntegral (i - m)
+ unsafeIndex b@(m,_) i = fromIntegral i - fromIntegral m
inRange (m,n) i = m <= i && i <= n
- unsafeRangeSize b@(_l,h) = unsafeIndex b h + 1
instance Read Int8 where
readsPrec p s = [(fromIntegral (x::Int), r) | (x, r) <- readsPrec p s]
instance Bits Int8 where
+ {-# INLINE shift #-}
+
(I8# x#) .&. (I8# y#) = I8# (word2Int# (int2Word# x# `and#` int2Word# y#))
(I8# x#) .|. (I8# y#) = I8# (word2Int# (int2Word# x# `or#` int2Word# y#))
(I8# x#) `xor` (I8# y#) = I8# (word2Int# (int2Word# x# `xor#` int2Word# y#))
data Int16 = I16# Int# deriving (Eq, Ord)
-- ^ 16-bit signed integer type
-instance CCallable Int16
-instance CReturnable Int16
-
instance Show Int16 where
showsPrec p x = showsPrec p (fromIntegral x :: Int)
instance Ix Int16 where
range (m,n) = [m..n]
- unsafeIndex b@(m,_) i = fromIntegral (i - m)
+ unsafeIndex b@(m,_) i = fromIntegral i - fromIntegral m
inRange (m,n) i = m <= i && i <= n
- unsafeRangeSize b@(_l,h) = unsafeIndex b h + 1
instance Read Int16 where
readsPrec p s = [(fromIntegral (x::Int), r) | (x, r) <- readsPrec p s]
instance Bits Int16 where
+ {-# INLINE shift #-}
+
(I16# x#) .&. (I16# y#) = I16# (word2Int# (int2Word# x# `and#` int2Word# y#))
(I16# x#) .|. (I16# y#) = I16# (word2Int# (int2Word# x# `or#` int2Word# y#))
(I16# x#) `xor` (I16# y#) = I16# (word2Int# (int2Word# x# `xor#` int2Word# y#))
readsPrec p s = [(fromInteger x, r) | (x, r) <- readsPrec p s]
instance Bits Int32 where
+ {-# INLINE shift #-}
+
(I32# x#) .&. (I32# y#) = I32# (word32ToInt32# (int32ToWord32# x# `and32#` int32ToWord32# y#))
(I32# x#) .|. (I32# y#) = I32# (word32ToInt32# (int32ToWord32# x# `or32#` int32ToWord32# y#))
(I32# x#) `xor` (I32# y#) = I32# (word32ToInt32# (int32ToWord32# x# `xor32#` int32ToWord32# y#))
readsPrec p s = [(fromIntegral (x::Int), r) | (x, r) <- readsPrec p s]
instance Bits Int32 where
+ {-# INLINE shift #-}
+
(I32# x#) .&. (I32# y#) = I32# (word2Int# (int2Word# x# `and#` int2Word# y#))
(I32# x#) .|. (I32# y#) = I32# (word2Int# (int2Word# x# `or#` int2Word# y#))
(I32# x#) `xor` (I32# y#) = I32# (word2Int# (int2Word# x# `xor#` int2Word# y#))
#endif
-instance CCallable Int32
-instance CReturnable Int32
-
instance Real Int32 where
toRational x = toInteger x % 1
instance Ix Int32 where
range (m,n) = [m..n]
- unsafeIndex b@(m,_) i = fromIntegral (i - m)
+ unsafeIndex b@(m,_) i = fromIntegral i - fromIntegral m
inRange (m,n) i = m <= i && i <= n
- unsafeRangeSize b@(_l,h) = unsafeIndex b h + 1
------------------------------------------------------------------------
-- type Int64
readsPrec p s = [(fromInteger x, r) | (x, r) <- readsPrec p s]
instance Bits Int64 where
+ {-# INLINE shift #-}
+
(I64# x#) .&. (I64# y#) = I64# (word64ToInt64# (int64ToWord64# x# `and64#` int64ToWord64# y#))
(I64# x#) .|. (I64# y#) = I64# (word64ToInt64# (int64ToWord64# x# `or64#` int64ToWord64# y#))
(I64# x#) `xor` (I64# y#) = I64# (word64ToInt64# (int64ToWord64# x# `xor64#` int64ToWord64# y#))
readsPrec p s = [(fromIntegral (x::Int), r) | (x, r) <- readsPrec p s]
instance Bits Int64 where
+ {-# INLINE shift #-}
+
(I64# x#) .&. (I64# y#) = I64# (word2Int# (int2Word# x# `and#` int2Word# y#))
(I64# x#) .|. (I64# y#) = I64# (word2Int# (int2Word# x# `or#` int2Word# y#))
(I64# x#) `xor` (I64# y#) = I64# (word2Int# (int2Word# x# `xor#` int2Word# y#))
#endif
-instance CCallable Int64
-instance CReturnable Int64
-
instance Real Int64 where
toRational x = toInteger x % 1
instance Ix Int64 where
range (m,n) = [m..n]
- unsafeIndex b@(m,_) i = fromIntegral (i - m)
+ unsafeIndex b@(m,_) i = fromIntegral i - fromIntegral m
inRange (m,n) i = m <= i && i <= n
- unsafeRangeSize b@(_l,h) = unsafeIndex b h + 1