[Haskell-cafe] Re: Shouldn't this loop indefinitely => take (last [0..]) [0..]

Don Stewart dons at galois.com
Thu Apr 3 18:13:06 EDT 2008

> Bryan O'Sullivan wrote:
> > It's not an infinite list.  It's a list of length maxBound::Int, as
> > required by the fact that take's first argument is an Int.  The second
> > argument is probably defaulting to Integer.
> Which, incidentally, also explains why Don couldn't reproduce it on a 64-
> bit system.  There, instead of hanging for about a minute before printing 
> out the list, it would hang for about 4 billion minutes.

It's also interesting how our 32 bit machines are fast enough now
to make Int indices noticeably problematic. And thankfully, 64 bit
machines are common enough now that the 32 bit Int issues are less of
an issue.

length, take, drop and index working on machine-sized Ints by default
are really a bit of a wart, aren't they?

-- Don

More information about the Haskell-Cafe mailing list