[Haskell-cafe] List comparisons and permutation group code

Tomasz Zielonka tomasz.zielonka at gmail.com
Thu Oct 19 15:27:56 EDT 2006

On Thu, Oct 19, 2006 at 01:37:16PM -0400, Cale Gibbard wrote:
> >Why is this so? I'd have thought that the equality function for lists
> >only forces evaluation of as many elements from its arguments as to
> >determine the answer.
> In order to determine if [1..length xs] has an element at all, you
> have to evaluate length xs, which involves forcing the entire spine of
> xs, because integers can't be partially evaluated. Computing lengths
> of lists is a great way to introduce strictness.

Right, so if Ints were represented as a datatype with Succ and Zero
constructors (so integers could be partially evaluated), then the
version with length would behave nicely on large and infinite lists :-)

Best regards

More information about the Haskell-Cafe mailing list