RFC: general sequences

Jon Fairbairn Jon.Fairbairn at cl.cam.ac.uk
Tue May 24 09:47:23 EDT 2005

On 2005-05-24 at 11:38BST Duncan Coutts wrote:
> On Tue, 2005-05-24 at 11:23 +0100, Malcolm Wallace wrote:
> > Also, there was debate at the time of the Haskell'98 committee about
> > whether the list operations with an Int argument would be better
> > taking an Integer.  I believe the consensus was positive towards
> > unbounded Integer, [...]
> There is also the argument that an Int is always big enough to be used
> as an index into a data structure that can fit in memory. This also
> applies to 64 bit machines because the Int just gets bigger. And so the
> argument goes, if Int is sufficient then there is the performance
> advantage of simple machine integers.

But that's not the real problem. Doing arithmetic on indexes
for these things forces the other variables in the
computation to be inferred as Int -- so instead of
defaulting to the safer Integer, other computations end up
being done in finite Ints.  

Best choice is Integral, then when nothing is specified you
get Integer, but if you care about performance and know that
either the other computations involved also fit in Int or
you've decorated your expressions with fromIntegral, you can
get the performance advantage of Int.


Jón Fairbairn                              Jon.Fairbairn at cl.cam.ac.uk

More information about the Libraries mailing list