Skip to content
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

Fix partiality in 'cycle' #256

Closed
chshersh opened this issue Apr 17, 2020 · 1 comment · Fixed by #275
Closed

Fix partiality in 'cycle' #256

chshersh opened this issue Apr 17, 2020 · 1 comment · Fixed by #275
Assignees
Labels
question Further information is requested

Comments

@chshersh
Copy link
Contributor

To my big surprise, the cycle function from base is partial: it fails on empty lists

ghci> :t cycle
cycle :: [a] -> [a]
ghci> cycle []
*** Exception: Prelude.cycle: empty list

It's a bit problematic, since we don't want to expose partial functions. I see the following options:

  1. Don't reexport cycle.
  2. Change its type to NonEmpty a -> NonEmpty a.
  3. Reimplement manually by returning empty list when empty list is given.

@vrom911, what do you think?

@chshersh chshersh added the question Further information is requested label Apr 17, 2020
@chshersh chshersh added this to the v0.7.0.0: Refiner milestone Apr 17, 2020
@vrom911
Copy link
Member

vrom911 commented Apr 18, 2020

I guess the less painful way would be to use the third option. And also this was my expectation of this function all along. I believe many people could expect such behaviour as well.

But in any case, this would be a breaking release. However, this is for the good 🙂

@chshersh chshersh self-assigned this May 11, 2020
chshersh added a commit that referenced this issue May 11, 2020
vrom911 pushed a commit that referenced this issue May 11, 2020
* [#256] Fix partiality in 'cycle'

Resolves #256

* Fix docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants