[GHC] #15081: Finite list becomes infinite after maping fractional function for high numbers

GHC ghc-devs at haskell.org
Mon Aug 13 00:50:33 UTC 2018


#15081: Finite list becomes infinite after maping fractional function for high
numbers
-------------------------------------+-------------------------------------
        Reporter:  Onsed             |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:
Operating System:  Linux             |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Incorrect result  |            Test Case:
  at runtime                         |  libraries/base/tests/enumNumeric
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4650
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by thomie):

 It is still possible to get an infinite list with `enumFromThenTo` and
 `Double`:

 {{{
 > [9007199254740992,9007199254740993..9007199254740994]::[Double]
 <infinite list>
 }}}


 Another funny result:
 {{{
 > [9007199254740993..9007199254740991]::[Double]
 [9.007199254740992e15,9.007199254740992e15]
 }}}

 Notice that `from` is bigger than `to`, so one would expect an empty list
 as a result.

 Like svenpanne said in comment:5:

 > The underlying problem stays: You can write more precise Integers than
 Double can represent, and enumerating floating point numbers is inherently
 fragile.

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


More information about the ghc-tickets mailing list