diff options
author | simonpj@microsoft.com <unknown> | 2010-11-16 17:15:10 +0000 |
---|---|---|
committer | simonpj@microsoft.com <unknown> | 2010-11-16 17:15:10 +0000 |
commit | 0656c72a8f4fda30c348bdf40449d105e4ce00ce (patch) | |
tree | 95c2c8ff9110ae91423c1abf7f106d4b5fd14460 /compiler/prelude | |
parent | e21c922fcdd1dac193bd8ff5670787daa3c21a12 (diff) | |
download | haskell-0656c72a8f4fda30c348bdf40449d105e4ce00ce.tar.gz |
Add warning for probable identities (fromIntegral and friends)
See Trac #4488. The basic idea is to check for
fun :: ty -> ty
where fun is one of
toIntegerName toRationalName
fromIntegralName realToFracName
There's a (documented) flag to control it -fwarn-identities.
Currently -Wall switches it on.
Diffstat (limited to 'compiler/prelude')
-rw-r--r-- | compiler/prelude/PrelNames.lhs | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/compiler/prelude/PrelNames.lhs b/compiler/prelude/PrelNames.lhs index e2e2dfe78b..40910f6c67 100644 --- a/compiler/prelude/PrelNames.lhs +++ b/compiler/prelude/PrelNames.lhs @@ -136,9 +136,12 @@ basicKnownKeyNames traversableClassName, -- Numeric stuff - negateName, minusName, - fromRationalName, fromIntegerName, - geName, eqName, + negateName, minusName, geName, eqName, + + -- Conversion functions + fromRationalName, fromIntegerName, + toIntegerName, toRationalName, + fromIntegralName, realToFracName, -- String stuff fromStringName, @@ -639,7 +642,7 @@ fstName, sndName :: Name fstName = varQual dATA_TUPLE (fsLit "fst") fstIdKey sndName = varQual dATA_TUPLE (fsLit "snd") sndIdKey --- Module PrelNum +-- Module GHC.Num numClassName, fromIntegerName, minusName, negateName, plusIntegerName, timesIntegerName, integerTyConName, smallIntegerName :: Name @@ -652,10 +655,11 @@ timesIntegerName = varQual gHC_INTEGER (fsLit "timesInteger") timesIntegerIdKe integerTyConName = tcQual gHC_INTEGER_TYPE (fsLit "Integer") integerTyConKey smallIntegerName = varQual gHC_INTEGER (fsLit "smallInteger") smallIntegerIdKey --- PrelReal types and classes +-- GHC.Real types and classes rationalTyConName, ratioTyConName, ratioDataConName, realClassName, integralClassName, realFracClassName, fractionalClassName, - fromRationalName :: Name + fromRationalName, toIntegerName, toRationalName, fromIntegralName, + realToFracName :: Name rationalTyConName = tcQual gHC_REAL (fsLit "Rational") rationalTyConKey ratioTyConName = tcQual gHC_REAL (fsLit "Ratio") ratioTyConKey ratioDataConName = conName gHC_REAL (fsLit ":%") ratioDataConKey @@ -663,7 +667,11 @@ realClassName = clsQual gHC_REAL (fsLit "Real") realClassKey integralClassName = clsQual gHC_REAL (fsLit "Integral") integralClassKey realFracClassName = clsQual gHC_REAL (fsLit "RealFrac") realFracClassKey fractionalClassName = clsQual gHC_REAL (fsLit "Fractional") fractionalClassKey -fromRationalName = methName gHC_REAL (fsLit "fromRational") fromRationalClassOpKey +fromRationalName = methName gHC_REAL (fsLit "fromRational") fromRationalClassOpKey +toIntegerName = methName gHC_REAL (fsLit "toInteger") toIntegerClassOpKey +toRationalName = methName gHC_REAL (fsLit "toRational") toRationalClassOpKey +fromIntegralName = varQual gHC_REAL (fsLit "fromIntegral") fromIntegralIdKey +realToFracName = varQual gHC_REAL (fsLit "realToFrac") realToFracIdKey -- PrelFloat classes floatingClassName, realFloatClassName :: Name @@ -1286,6 +1294,12 @@ fromStringClassOpKey = mkPreludeMiscIdUnique 125 toAnnotationWrapperIdKey :: Unique toAnnotationWrapperIdKey = mkPreludeMiscIdUnique 126 +-- Conversion functions +fromIntegralIdKey, realToFracIdKey, toIntegerClassOpKey, toRationalClassOpKey :: Unique +fromIntegralIdKey = mkPreludeMiscIdUnique 127 +realToFracIdKey = mkPreludeMiscIdUnique 128 +toIntegerClassOpKey = mkPreludeMiscIdUnique 129 +toRationalClassOpKey = mkPreludeMiscIdUnique 130 ---------------- Template Haskell ------------------- -- USES IdUniques 200-399 |