How to detect finite/infinite lists?

Juanma Barranquero lektu at
Thu Sep 18 22:58:09 EDT 2003

On Thu, 18 Sep 2003 14:20:46 -0400, "David Barton" <dlb at> wrote:

> that's halting problem equivalent.

Yes, I know it's a halting problem, in the general case.

But the compiler could try to say if it knows it *is* a finite list. So:

x = [1..10]
y = [1..]
z = someFunctionOrOther

knownToBeFinite x -> should return Just True
knownToBeFinite y -> should return Just False
knownToBeFinite z -> should return Nothing ("I don't know").

or something along these lines.

> Nope.

Ok. Thanks,


More information about the Haskell-Cafe mailing list