-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Data.ByteString.Lazy.compareLength #300
Conversation
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.
Cool!
Tests go into tests/Properties.hs
Almost there! We can also benefit from rewrite rules, similar to Do not forget to re-export this function from |
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.
Thanks!
@gutjuri merged, thanks! |
-- Required for rewrite rules for 'compareLength' | ||
negateOrdering :: Ordering -> Ordering | ||
negateOrdering LT = GT | ||
negateOrdering EQ = EQ | ||
negateOrdering GT = LT | ||
|
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.
This function looks redundant to me, it is just compare EQ
.
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.
Should I open a miniature pull request to delete negateOrdering
and replace its call site with compare EQ
?
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.
Yes, much appreciated. Could you please also combine all rules for compareLength
under a single RULES
pragma?
related to #298
I tested the function in GHCi.
Unfortunately I do not yet understand how to add tests to the testsuite.
I'd be great if someone could give me a point in the right direction on where to add tests.
Concerning the documentation: I described the compareLength as being O(n) (where n is the length of the ByteString). This is a bit imprecise, because it neglects the
Int
parameter entirely. However, I was not sure on how to refer to this parameter in the documentation.