sizeFM type

ajb at spamcop.net ajb at spamcop.net
Mon Apr 26 21:43:44 EDT 2004


G'day all.

Quoting "S. Alexander Jacobson" <haskell at alexjacobson.com>:

> Sun and Dell both sell 64-bit boxes.  But the core
> question is why have two different types at all?

Operations on an Integer (e.g. addition, multplication) are not O(1).
On an Int, they are (for all intents and purposes).  This is a
sufficiently important (IMO) difference that it's worthwhile to
distinguish between integral types which the hardware can handle
natively and others.

In this case, I think the types are both wrong:

>    hFileSize::Handle -> IO Integer

Should be :: Handle -> IO Word64

Yes, Word64 is a dirty type.  In general, anything which interfaces
directly to the operating system is going to have a dirty type.  Such
is life.

>    take::forall a. Int -> [a]->[a]

Should be :: (Integral a) => a -> [b] -> [b]

> And re sizeFM, I would note that Google has more
> than 2^31 pages indexed in memory.

I would note, in addition, that they don't have that many pages indexed
on a single machine.  Almost nobody has a database with that many records
on a single machine, even those who have clusters of 64 bit machines.

I would make sizeFM an Int, but define Int to be the most reasonable
integral type for the underlying platform, and at least 32 bits in size.

Cheers,
Andrew Bromage


More information about the Glasgow-haskell-users mailing list