
#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 simonpj):
Wait, are you saying that typing 1.7e1234111111111111111111111 to take minutes and use up more than 20G of memory (residence, not allocation!) not surprising?
I agree: that's absurd! HOwever, unlike Python, we can't just compute a suitable `Float`, because literals are overloaded. The [https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-240003.2 Report] does say that a floating point literal like `1e100` means `fromRational (n % d)` where "the integers n and d are chosen so that n/d = f". I suspect that in computing `17 % 10000000000000000000000` we try to find the GCD of the two before we even start with `fromRational`, and you can see this isn't going to end well. What to do? Probably we need a special case for `fromRational :: Rational -> Float` (and similarly `Double`); and maybe even a special literal representation inside GHC for `Rational`s of form `N / 10000000000000` for some number of zeros. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15646#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler