[GHC] #15646: ghci takes super long time to find the type of large fractional number
GHC
ghc-devs at haskell.org
Mon Sep 17 14:31:55 UTC 2018
#15646: ghci takes super long time to find the type of large fractional number
-------------------------------------+-------------------------------------
Reporter: Johannkokos | Owner:
| JulianLeviston
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: GHCi | Version: 8.4.3
Resolution: | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by monoidal):
The literal `1e100` means `fromRational (100...000 :: Rational)`, as
specified in Haskell report. Constructing this number takes time and space
proportional to the number of zeroes. It's not surprising it crashes badly
when the exponent has 10 digits or more. On the other hand, the type of
`10^1000000000` can be found quickly because the expression is not
evaluated.
The big integer is already created during parsing (as can be seen by
compiling `main = print 1e1000` with `-ddump-parsed-ast`). With
`-XNumDecimals`, we need to process the literal before we can tell its
type: `1.234e3` is a valid `Integer` but `1.234e2` is not. I don't see any
easy way to fix this and preserve backwards compatibility. Perhaps we
could show a parse error when attempting to create an integer with an
unrealistic exponent.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15646#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list