This module provides an infinite list type and operations thereon.

Haskell has two outstanding features:

laziness, which in particular allows infinite data structures;

a very strong type system.

In that light, it's a bit embarrassing that its default libraries do not allow one to express the infinitude of, say, a list. For example, repeat has type a → [a] , when it of course should not return a finite list.

This module defines an infinite list data structure and provides all the standard list-manipulating functions that make sense on them. The advantages of using this over a standard list are:

Type safety and clarity. We are prevented from using nonsensical functions on infinite lists. These include the functions: last , init , null , length , foldl , scanr , scanl , replicate , reverse , any (etc.), isSuffixOf , 'Data.List.(\)', union , unionBy , intersect , intersectBy , transpose , deleteFirstsBy , subsequences , nonEmptySubsequences , permutations , sort , sortBy , sum (etc.), elem (etc.), lookup , findIndex , elemIndex , isInfixOf , nub .

, , , , , , , , , (etc.), , 'Data.List.(\)', , , , , , , , , , , , (etc.), (etc.), , , , , . No pattern-matching on nil. Where you can identify that [] will never be present, using a list forces you to either write clunky error-generating pattern matches, or alternatively put up with compiler warnings about incompete pattern matches. Code is simplified.

will never be present, using a list forces you to either write clunky error-generating pattern matches, or alternatively put up with compiler warnings about incompete pattern matches. Code is simplified. Faster code. We do not need or want runtime pattern-matches on a data constructor which will never occur. Haskell compilers love single-constructor datatypes: http://www.haskell.org/haskellwiki/Performance/Data_types#Single-constructor_datatypes