-
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 stimes more efficiently #301
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.
stimes
for a negative argument should throw an error similar to stimesDefault
.
Is strict stimes
correct for n = 0
?
I've just taken the liberty to throw an error on any non-negative input to |
Sorry for confusion, I should have pointed you to |
Thanks, looks reasonable to me. Please go ahead with tests. It's enough to check that |
Any Idea on how to get to |
I'm afraid it's implemented using stimes which wouldn't help us at all |
Oh just realized its using stimes of the wrapped monoid nvm |
Doesn't look like the strict version is working |
Turns out |
Looks very nice, thanks! Please fix tests for GHC < 8.0 by adding |
Ah, that's me being stupid. Since |
Done |
@Bodigrim just did, sorry for the delay |
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.
A few more wibbles – nearly done.
| n < 0 = error "stimes: non-negative multiplier expected" | ||
| n == 0 = mempty | ||
| len == 0 = mempty | ||
| n == 1 = BS fp len |
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.
Does returning BS fp len
instead of a variable bound to the BS
pattern result in additional allocations?
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.
Just checked with ddump-simpl and couldn't see any differences outside of different identifiers.
ddump-core-stats also returns the same amount of Terms, Types and Coercions, so I think it's optimized away. Wouldn't say no to assigning it to a name though if you believe it would be more readable
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 assembly generated with ddump-asm also looks essentially the same, up to renaming.
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 for investigating! 👍
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.
Thank you, @elikoga! :)
@elikoga last hurdle before merge: could you please fix tests? Seems |
I don't believe that Properties.hs has changed since c39c1e7 and I'm honestly quite confused what changes to make to fix it. |
Whoops my fault |
Co-authored-by: Bodigrim <[email protected]>
Co-authored-by: Bodigrim <[email protected]>
Looks like it works; If accepted please add the hacktoberfest-accepted label. |
Thanks, merged! |
As requested in #299
I didn't write any test cases yet