Re: [GHC] #5279: numericEnumFromThen breaks standard behaviour in presence of ⊥

GHC cvs-ghc at haskell.org
Mon Jun 27 04:20:14 CEST 2011


#5279: numericEnumFromThen breaks standard behaviour in presence of ⊥
---------------------------------+------------------------------------------
    Reporter:  ehird             |       Owner:                             
        Type:  bug               |      Status:  new                        
    Priority:  normal            |   Component:  Compiler                   
     Version:  7.0.3             |    Keywords:                             
    Testcase:                    |   Blockedby:                             
          Os:  Unknown/Multiple  |    Blocking:                             
Architecture:  Unknown/Multiple  |     Failure:  Incorrect result at runtime
---------------------------------+------------------------------------------

Comment(by ehird):

 Replying to [ticket:5279 ehird]:
 > Haskell 2010 (and, for what it's worth, 98) require the following
 behaviour for `numericEnumFromThen`:
 >
 > {{{
 > numericEnumFromThen n m =  iterate (+(m-n)) n
 > }}}
 >
 > but GHC has:
 >
 > {{{
 > numericEnumFromThen n m = n `seq` m `seq` (n : numericEnumFromThen m
 (m+m-n))
 > }}}
 >
 > The standard evaluation of `numericEnumFromThen 0.0 undefined` is
 equivalent to `0.0 : repeat undefined`, but GHC evaluates it as
 `undefined`:
 >
 > {{{
 > Prelude> [0.0, undefined..]
 > *** Exception: Prelude.undefined
 > }}}
 >
 > So unfortunately, this optimisation changes semantics in violation of
 the Report.
 >
 > `numericEnumFrom` also suffers from this issue; the evaluation of
 `numericEnumFrom undefined` should be equivalent to `repeat undefined`,
 but GHC evaluates it as `undefined`. This is a more minor issue, however.
 :)
 >
 > (Tested with 7.0.3 and whatever version lambdabot uses on freenode.)

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



More information about the Glasgow-haskell-bugs mailing list