Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#2533 closed proposal (fixed)

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: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

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 (3)

generic-negative-index (18.8 KB) - added by japple 9 years ago.
generic-negative-index-test (48.4 KB) - added by japple 9 years ago.
generic-negative-index-report (26.9 KB) - added by japple 9 years ago.

Download all attachments as: .zip

Change History (12)

Changed 9 years ago by japple

Attachment: generic-negative-index added

comment:1 Changed 9 years ago by japple

Deadline: Sept 7

comment:2 Changed 9 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.

comment:3 Changed 9 years ago by igloo

difficulty: Unknown
Milestone: Not GHC

Changed 9 years ago by japple

Attachment: generic-negative-index-test added

Changed 9 years ago by japple

comment:4 Changed 9 years ago by japple

Owner: set to malcolm.wallace@…

Malcolm, can you push these changes?

comment:5 Changed 9 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.

comment:6 Changed 9 years ago by igloo

Owner: changed from Igloo to igloo

comment:7 Changed 9 years ago by igloo

Resolution: fixed
Status: newclosed

I've applied the patches, thanks!

comment:8 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:9 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple
Note: See TracTickets for help on using tickets.