cycle package:relude

Creates an infinite list from a finite list by appending the list to itself infinite times (i.e. by cycling the list). Unlike cycle from Data.List, this implementation doesn't throw error on empty lists, but returns an empty list instead.
>>> cycle []
[]

>>> take 10 $ cycle [1,2,3]
[1,2,3,1,2,3,1,2,3,1]
A generalization of cycle to an arbitrary Semigroup. May fail to terminate for some values in some semigroups.

Examples

>>> take 10 $ cycle1 [1, 2, 3]
[1,2,3,1,2,3,1,2,3,1]
>>> cycle1 (Right 1)
Right 1
>>> cycle1 (Left 1)
* hangs forever *