-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
1 addition
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e4ffec3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Case analysis on old code:
length xs < l
:clen = 0
length xs == l
:clen = 1
Remaining case is
length xs > l
, but plugging in a concrete number for simplicity:length xs == l + 1
:clen = 1
The old code fails when the length of xs isn't an integer multiple of l. Case analysis on new code:
length xs < l
:clen = 1
length xs == l
:clen = 2
Remaining case is
length xs > l
, but plugging in a concrete number for simplicity:length xs == l + 1
:clen = 2
The new code fixes the failing cases. I have written code which does exactly this so I might be the author of the code in question. My reason for writing the code was to experiment with work distribution across cores and I assumed that l would divide the length of xs. Calling
segment 2 [1,2]
and getting[[1,2], []]
as result is semantically correct but not the desired operational behaviour.e4ffec3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the old code was designed to only work (well) with
length xs
being a multiple ofl
. However, sincexs
is generated byQuickCheck
andl
is 1024, this is almost never true.Another fix would be documenting the limitation and constraining the
QuickCheck
generator.e4ffec3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other hand the function is not yet used with a
QuickCheck
generator...e4ffec3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code wasn't really designed--it was more of an experiment that I had laying around on the side. I kept running into regressions with that code so I added it to the test suite. Your patched version is semantically correct and catches null vector bugs in plugins so we should just leave it at that.