[GHC] #9231: 7.8 regression in Read instance of Data.Fixed.Pico

GHC ghc-devs at haskell.org
Tue Jun 24 09:19:29 UTC 2014


#9231: 7.8 regression in Read instance of Data.Fixed.Pico
-------------------------------------+------------------------------------
        Reporter:  leonbaum2         |            Owner:
            Type:  bug               |           Status:  new
        Priority:  highest           |        Milestone:  7.8.3
       Component:  libraries/base    |          Version:  7.8.2
      Resolution:                    |         Keywords:  regression
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by hvr):

 I can't think of any cleaner fix for this other than radically rewriting
 `Data.Fixed` or extracting the 10-base exponent via

 {{{#!hs
 e = ceiling (logBase 10 (fromInteger r) :: Double)
 }}}

 and having the code read like

 {{{#!hs
 convertFixed :: forall a . HasResolution a => Lexeme -> ReadPrec (Fixed a)
 convertFixed (Number n)
  | Just (i, f) <- numberToFixed e n =
     return (fromInteger i + (fromInteger f / fromInteger r))
     where r = resolution (undefined :: Fixed a)
           e = ceiling (logBase 10 (fromInteger r) :: Double)
 convertFixed _ = pfail
 }}}

 (Note that `numberToFixed` also expects an exponent rather than a power-
 of-10)

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


More information about the ghc-tickets mailing list