Bignums in Haskell

karczma at info.unicaen.fr karczma at info.unicaen.fr
Tue Jun 21 18:47:02 EDT 2005


John Meacham writes: 

> I wonder if it would be feasable to implement arbitrary precision
> integers in pure haskell. unboxed values would probably want to be used
> in some places for speed and it would be very motivating to improve
> ghc's optimizer. There should be no reason manually unboxed haskell code
> should compile slower than C.  

Of course, bignums (integers) can be quite nicely implemented in Haskell,
this is btw. a known student exercise. The implementation is nice, elegant,
etc., but the efficiency... This is not only having unboxed chunks, but
also the global policy of memory allocation. Putting number chunks in lazy
lists involves a substantial overhead. I am not sure how slow it will be,
since our pedagogic games didn't care at all, but we can try to benchmark
it one day...
 

Jerzy Karczmarczuk 




More information about the Glasgow-haskell-users mailing list