Opened 4 years ago

Closed 4 years ago

#5279 closed bug (invalid)

numericEnumFromThen breaks standard behaviour in presence of ⊥

Reported by: ehird Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.0.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

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.)

Change History (2)

comment:1 in reply to: ↑ description Changed 4 years ago by ehird

Replying to 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.)

comment:2 Changed 4 years ago by ehird

  • Resolution set to invalid
  • Status changed from new to closed

Oops. I was trying to fix an error (additional "> " before "Prelude>"). Sorry.

But it turns out this is invalid -- "For all four of these Prelude numeric types, all of the enumFrom family of functions are strict in all their arguments." Sorry!

Note: See TracTickets for help on using tickets.