-
Notifications
You must be signed in to change notification settings - Fork 49
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
Rename scanrLazy to scanlLazy and fix arg order #161
Conversation
As it stands this will be a breaking change, which is less than ideal. Can we add a |
The function It's entirely possible that I'm wrong here and that there is a better way to implement this function. [1] - https://hackage.haskell.org/package/base-4.12.0.0/docs/Prelude.html#v:scanr |
@hdgarrood I've added back |
Any thoughts on this PR? |
This seems okay to me 👍 I think it's languished a bit because we generally try to bunch breaking changes up together so that people don't have to deal with them too often, but since 0.14 is coming up soon we can hopefully get this change in there. |
Actually, can you add a test for stack safety? That is, run |
@hdgarrood sounds good! I actually don't think this PR is backwards incompatible as it still includes a I'll add a stack safety test, though I'm somewhat concerned that it isn't actually stack safe. |
The behaviour of |
I've added the test at it indeed is not stack safe. I'll take a look soon into fixing this. |
Oh, I just spotted that this contradicts what I said before. Ignore that older comment, I don't know what I was thinking, haha. |
I'm at a bit of a loss as to how to make I highly doubt anyone is actually using it in the current state and, if they are, they simply need to reverse two arguments and rename the function. Otherwise, if you have advice for making |
Maybe |
@natefaubion that is genius and now seems so obvious :) I've updated the code and it seems to be stack safe. |
Ok so now that I actually understand what scanrLazy is doing after seeing it expressed in terms of scanlLazy I’m kind of skeptical of it. Does it even make sense to describe the function as “lazy” when simply getting the head of the result requires forcing the entire input list? It just seems like a weird thing to want to do. Perhaps it’s best to get rid of it after all? Especially since nobody has asked for it as far as I’m aware. (Sorry that I keep changing my mind.) |
No, it doesn't really make sense. A right scan isn't very useful for this reason. It's similar to a lazy foldl. |
I agree. So considering it is a breaking release, should we simply remove it? |
Sounds good to me. Sorry for leading you round in a big circle to end up right back where you started! |
No problem! I've removed |
To clean up the commit history, should he just force-push the original commit? |
You can also just squash and merge.
…On Sun, Feb 23, 2020 at 6:02 PM JordanMartinez ***@***.***> wrote:
To clean up the commit history, should he just force-push the original
commit?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#161?email_source=notifications&email_token=AAAA3UFHBXIGNS4GRPV3SCLREMFBTA5CNFSM4IL2KN6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMWLLHI#issuecomment-590132637>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAA3UBRUXDCVRHTOIOA2RLREMFBTANCNFSM4IL2KN6A>
.
|
The previously-named scanrLazy was actually folding to the left. I've renamed the function and fixed the argument ordering for the folding function.
I've squashed all commits down to a single commit. |
If we don't want to maintain a |
I was going to suggest just |
Happy to rename it to either. Please let me know what you two prefer. |
Note that scanl already exists, so consistency might be a concern as well. |
If we drop the Lazy suffix should we also rename Data.List.Lazy.foldrLazy to foldr for consistency? |
Yeah, we should probably go for consistency. I don't like that there can be two functions named the same thing where the only difference is the module from which they are imported. Until one knows to check their imports, it can make reading compiler errors confusing. However, that's more of a beginner issue. |
I agree that consistency is good but I think avoiding unnecessary breaking changes generally trumps consistency. I didn't realise this module already has a |
So let's call it |
If we prefer to not rename foldrLazy then shouldn’t we keep scanlLazy and merge this as is? |
That works for me too, I guess. Is the argument that |
Yes, exactly. Even though I’m not fond of the Lazy prefix since we tend to encourage disambiguation by qualified imports elsewhere in the core libraries, at least scanlLazy and foldrLazy remain consistent. |
The previously-named scanrLazy was actually folding to the left. I've
renamed the function and fixed the argument ordering for the folding
function.
Fixes #159