summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Real.hs
diff options
context:
space:
mode:
authorSeraphime Kirkovski <kirkseraph@gmail.com>2016-06-06 12:29:38 +0200
committerBen Gamari <ben@smart-cactus.org>2016-06-06 15:07:18 +0200
commita90085bd45239fffd65c01c24752a9bbcef346f1 (patch)
tree41a85ba36720d8fba0a3296ea7a844dd9fc0042a /libraries/base/GHC/Real.hs
parent48e9a1f5521fa3185510d144dd28a87e452ce134 (diff)
downloadhaskell-a90085bd45239fffd65c01c24752a9bbcef346f1.tar.gz
Add @since annotations to base instances
Add @since annotations to instances in `base`. Test Plan: * ./validate # some commets shouldn't break the build * review the annotations for absurdities. Reviewers: ekmett, goldfire, RyanGlScott, austin, hvr, bgamari Reviewed By: RyanGlScott, hvr, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2277 GHC Trac Issues: #11767
Diffstat (limited to 'libraries/base/GHC/Real.hs')
-rw-r--r--libraries/base/GHC/Real.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/libraries/base/GHC/Real.hs b/libraries/base/GHC/Real.hs
index 3a97f1f18c..fbd9f16483 100644
--- a/libraries/base/GHC/Real.hs
+++ b/libraries/base/GHC/Real.hs
@@ -236,9 +236,11 @@ numericEnumFromThenTo e1 e2 e3
-- Instances for Int
--------------------------------------------------------------
+-- | @since 2.0.1
instance Real Int where
toRational x = toInteger x :% 1
+-- | @since 2.0.1
instance Integral Int where
toInteger (I# i) = smallInteger i
@@ -286,9 +288,11 @@ instance Integral Int where
-- Instances for @Word@
--------------------------------------------------------------
+-- | @since 2.01
instance Real Word where
toRational x = toInteger x % 1
+-- | @since 2.01
instance Integral Word where
quot (W# x#) y@(W# y#)
| y /= 0 = W# (x# `quotWord#` y#)
@@ -316,6 +320,7 @@ instance Integral Word where
-- Instances for Integer
--------------------------------------------------------------
+-- | @since 2.0.1
instance Real Integer where
toRational x = x :% 1
@@ -331,6 +336,7 @@ instance Real Integer where
-- happen because they are all marked with NOINLINE pragma - see documentation
-- of integer-gmp or integer-simple.
+-- | @since 2.0.1
instance Integral Integer where
toInteger n = n
@@ -364,11 +370,13 @@ instance Integral Integer where
-- Instances for @Ratio@
--------------------------------------------------------------
+-- | @since 2.0.1
instance (Integral a) => Ord (Ratio a) where
{-# SPECIALIZE instance Ord Rational #-}
(x:%y) <= (x':%y') = x * y' <= x' * y
(x:%y) < (x':%y') = x * y' < x' * y
+-- | @since 2.0.1
instance (Integral a) => Num (Ratio a) where
{-# SPECIALIZE instance Num Rational #-}
(x:%y) + (x':%y') = reduce (x*y' + x'*y) (y*y')
@@ -379,6 +387,7 @@ instance (Integral a) => Num (Ratio a) where
signum (x:%_) = signum x :% 1
fromInteger x = fromInteger x :% 1
+-- | @since 2.0.1
{-# RULES "fromRational/id" fromRational = id :: Rational -> Rational #-}
instance (Integral a) => Fractional (Ratio a) where
{-# SPECIALIZE instance Fractional Rational #-}
@@ -389,15 +398,18 @@ instance (Integral a) => Fractional (Ratio a) where
| otherwise = y :% x
fromRational (x:%y) = fromInteger x % fromInteger y
+-- | @since 2.0.1
instance (Integral a) => Real (Ratio a) where
{-# SPECIALIZE instance Real Rational #-}
toRational (x:%y) = toInteger x :% toInteger y
+-- | @since 2.0.1
instance (Integral a) => RealFrac (Ratio a) where
{-# SPECIALIZE instance RealFrac Rational #-}
properFraction (x:%y) = (fromInteger (toInteger q), r:%y)
where (q,r) = quotRem x y
+-- | @since 2.0.1
instance (Show a) => Show (Ratio a) where
{-# SPECIALIZE instance Show Rational #-}
showsPrec p (x:%y) = showParen (p > ratioPrec) $
@@ -409,6 +421,7 @@ instance (Show a) => Show (Ratio a) where
-- Haskell 98 [Sep 08, #1920]
showsPrec ratioPrec1 y
+-- | @since 2.0.1
instance (Integral a) => Enum (Ratio a) where
{-# SPECIALIZE instance Enum Rational #-}
succ x = x + 1