[commit: ghc] master: Use fromRational when pre-computing fromRational literals (6bb741b)
Ian Lynagh <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.cvs.ghc |
|---|---|
| Message-ID | <[email protected]> |
Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master http://hackage.haskell.org/trac/ghc/changeset/6bb741b12cf0829dd00fe9b16abc2941610cd155 >--------------------------------------------------------------- commit 6bb741b12cf0829dd00fe9b16abc2941610cd155 Author: Ian Lynagh <[email protected]> Date: Sun Oct 21 18:03:17 2012 +0100 Use fromRational when pre-computing fromRational literals This makes it easier to be confident that the optimisation gives the right answer. >--------------------------------------------------------------- compiler/prelude/PrelRules.lhs | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/compiler/prelude/PrelRules.lhs b/compiler/prelude/PrelRules.lhs index 2f4d62f..72cb878 100644 --- a/compiler/prelude/PrelRules.lhs +++ b/compiler/prelude/PrelRules.lhs @@ -50,6 +50,7 @@ import Util import Control.Monad import Data.Bits as Bits import Data.Int +import Data.Ratio import Data.Word \end{code} @@ -1177,7 +1178,7 @@ match_rationalTo mkLit _ _ id_unf [xl, yl] | Just (LitInteger x _) <- exprIsLiteral_maybe id_unf xl , Just (LitInteger y _) <- exprIsLiteral_maybe id_unf yl , y /= 0 - = Just (mkLit (fromInteger x/fromInteger y)) + = Just (mkLit (fromRational (x % y))) match_rationalTo _ _ _ _ _ = Nothing match_decodeDouble :: DynFlags