returning to cost of Integer

Bulat Ziganshin bulat.ziganshin at
Tue Aug 1 06:57:31 EDT 2006

Hello John,

Tuesday, August 1, 2006, 5:19:37 AM, you wrote:

> This has made me wonder whether we are better off getting rid of the
> small integer optimization and turning Integer into a straight
> unboxable ForeignPtr to a GMP number. this would also mean we could use
> the standard GMP that comes with the system since ForeignPtr will take
> care of GCing Integers itself. This was my plan with jhc, but at the
> moment, Integer is still just intmax_t.

> Another option would be to keep the small integer optimization but make
> it CPR

> data Integer = Integer Int# !(Ptr MPZ)

> where if the Ptr is NULL then the Int# contains the value...

John, Integer values in many cases used just to keep small numbers
which can be larger than 2^32 (2^64) in rare cases. For example,
"type FileSize = Integer" used in IO library. so it's important to
keep operations on small Integers fast and use minimum amount of

how about:

data Integer = S# Int# | L# !(ForeignPtr MPZ)


Best regards,
 Bulat                            mailto:Bulat.Ziganshin at

More information about the Glasgow-haskell-users mailing list