[GHC] #15646: ghci takes super long time to find the type of large fractional number

GHC ghc-devs at haskell.org
Mon Oct 15 15:41:56 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 simonpj):

 Would you like to lay out the design, and its moving parts, in a draft
 Note that will eventually be part of the source code?

 eg I think (but am not sure) that your question is this: in representation
 of a literal fractional number:
 {{{
 data FractionalLit
   = FL { fl_text :: SourceText     -- How the value was written in the
 source
        , fl_neg :: Bool            -- See Note [Negative zero]
        , fl_mantissa, fl_exp :: Integer
                                    -- Denotes <mantissa>E<exp>
        }
 }}}
 in what number base is the `fl_exp` expressed?  For example

 * `1.7e30` has `fl_mantissa = 17`, and `fl_exp = 29`, assuming base 10
 * But what about `0x5e.ff2p12`?  Here the mantissa can reasonably still be
 `0x5eff`, but the exponent must (presumably, given
 [http://downloads.haskell.org/~ghc/master/users-guide/glasgow_exts.html
 #hexadecimal-floating-point-literals the spec]) be in base 2.

 To me it sounds as if we need another field for the exponent base to
 accurately represent the literal. So the value of the literal is `mantissa
 * (base ^ exponent)`.   My instinct is just to make the a sum-type rather
 than another `Int` or `Integer`:
 {{{
 data ExponentBase = Base10 | Base 2
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15646#comment:33>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list