sanctuary-js / sanctuary

:see_no_evil: Refuge from unsafe JavaScript
https://sanctuary.js.org
MIT License
3.03k stars 94 forks source link

array: generalize S.takeLast and S.dropLast #630

Closed davidchambers closed 5 years ago

davidchambers commented 5 years ago

The implementations are not as efficient as they could be, but I want to avoid spreading complexity currently confined to _takeDrop.

masaeedu commented 5 years ago

If I'm right about the applicative constraint not being required in #627, then we probably don't need it here as well.

davidchambers commented 5 years ago

You have raised a good point, @Bradcomp; I had not considered infinite structures. I would not expect these functions to work on infinite structures, so I do not find the behaviour surprising, but it is a shame that the type signatures do not accurately convey the constraints.

https://github.com/sanctuary-js/sanctuary/pull/627#issuecomment-487275940 applies here too, @masaeedu, so I will merge this pull request in its current form. If it turns out that I have misunderstood the constraints, we can relax the constraints on S.take, S.drop, S.takeLast, and S.dropLast in another pull request. :)