#4488: Warn about unnecessary fromIntegral and other conversions
-------------------------------------------+--------------------------------
Reporter: mitar | Owner:
Type: feature request | Status: closed
Priority: normal | Milestone: 7.2.1
Component: Compiler | Version: 6.12.3
Resolution: fixed | Keywords:
Testcase: deSugar/should_compile/T4488 | Blockedby:
Difficulty: | Os: Unknown/Multiple
Blocking: | Architecture: Unknown/Multiple
Failure: None/Unknown |
-------------------------------------------+--------------------------------
Changes (by simonpj):
* status: new => closed
* testcase: => deSugar/should_compile/T4488
* resolution: => fixed
Comment:
OK, your wishes are granted
{{{
Tue Nov 16 17:15:10 GMT 2010 [email protected]
* 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.
M ./compiler/deSugar/Desugar.lhs -3 +7
M ./compiler/deSugar/DsExpr.lhs -3 +37
M ./compiler/main/DynFlags.hs -1 +4
M ./compiler/prelude/PrelNames.lhs -7 +21
M ./docs/users_guide/flags.xml +8
M ./docs/users_guide/using.xml +15
}}}
I didn't do `fromInteger` and `fromRational` there are zillions of them
generated by literals. ("`1`" means "`fromInteger 1`" etc.) And many of
them are identities. I didn't think it was worth trying to distinguish
user-written calls to `fromInteger` from these implicit ones, although
that would be possible.
In compiling the libraries I found lots of redundant `fromIntegral` calls,
plus one redundant `toRational`.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4488#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs