Skip to content

Fix partiality in 'cycle' #256

@chshersh

Description

@chshersh

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?

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions