Ticket #2533 (closed proposal: fixed)

Opened 5 years ago

Last modified 5 years ago

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

Reported by: japple Owned by: igloo
Priority: normal Milestone: Not GHC
Component: libraries/base Version: 6.8.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

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 5 years ago.
generic-negative-index-test Download (48.4 KB) - added by japple 5 years ago.
generic-negative-index-report Download (26.9 KB) - added by japple 5 years ago.

Change History

Changed 5 years ago by japple

Changed 5 years ago by japple

Deadline: Sept 7

Changed 5 years 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 5 years ago by igloo

  • difficulty set to Unknown
  • milestone set to Not GHC

Changed 5 years ago by japple

Changed 5 years ago by japple

Changed 5 years ago by japple

  • owner set to malcolm.wallace@…

Malcolm, can you push these changes?

Changed 5 years 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 5 years ago by igloo

  • owner changed from Igloo to igloo

Changed 5 years ago by igloo

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

I've applied the patches, thanks!

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

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