Ticket #2533 (closed proposal: fixed)

Opened 18 months ago

Last modified 17 months ago

Generic functions that take integral arguments should work the same way as their prelude counterparts

Reported by: japple Owned by: igloo
Component: libraries/base Version: 6.8.3
Keywords: Cc:
Operating System: Unknown/Multiple
Test Case: Architecture: Unknown/Multiple
Type of failure:

Description

The Prelude functions drop, take, and splitAt are unfailing (never call error). This patch changes the Data.List generic versions to behave the same way. At present, they call error on negative arguments.

quickCheck (\x n -> take n x == genericTake n x) quickCheck (\x n -> drop n x == genericDrop n x) quickCheck (\x n -> splitAt n x == genericSplitAt n x)

The library submission procedures say

If the changes update Haddoc [sic] documentation, also attach the resulting Haddock-generated pages.

Haddock fails on the file because of existing CPP commands.

Attachments

generic-negative-index Download (18.8 KB) - added by japple 18 months ago.
generic-negative-index-test Download (48.4 KB) - added by japple 17 months ago.
generic-negative-index-report Download (26.9 KB) - added by japple 17 months ago.

Change History

Changed 18 months ago by japple

Changed 18 months ago by japple

Deadline: Sept 7

Changed 18 months ago by malcolm.wallace@…

I agree that the generic versions should match the behaviour of the Int-specific versions. As I recall, the Int-specific Prelude functions originally called error, but this was changed around the time of Haskell 1.4/H'98. The failure to change the generic versions at the same time was just an oversight.

Changed 18 months ago by igloo

  • difficulty set to Unknown
  • milestone set to Not GHC

Changed 17 months ago by japple

Changed 17 months ago by japple

Changed 17 months ago by japple

  • owner set to malcolm.wallace@…

Malcolm, can you push these changes?

Changed 17 months ago by malcolm.wallace@…

  • owner changed from malcolm.wallace@… to Igloo

Igloo, I have applied the final patch to the haskell-report repository, but am guessing that you might prefer to validate the changes to base and testsuite before pushing them.

Changed 17 months ago by igloo

  • owner changed from Igloo to igloo

Changed 17 months ago by igloo

  • status changed from new to closed
  • resolution set to fixed

I've applied the patches, thanks!

Changed 17 months ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 17 months ago by simonmar

  • os changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.