Unpack primitive types by default in data

Roman Leshchinskiy rl at cse.unsw.edu.au
Fri Feb 17 22:11:16 CET 2012


On 17/02/2012, at 17:51, Johan Tibell wrote:

> On Fri, Feb 17, 2012 at 12:52 AM, Roman Leshchinskiy <rl at cse.unsw.edu.au> wrote:
>> I'm not convinced that this is a good idea because it doesn't treat all
>> types equally. The comparison with Java is problematic, IMO, because in
>> Java 'int' is always called 'int' whereas in Haskell, it might be called
>> many different things.
>> 
>> To better understand the proposal, which of the types below would you want
>> to be unboxed automatically?
>> 
>> data A = A Int#
>> newtype B = B A
>> data C = C !B
>> data D = D !C
>> data E = E !()
>> data F = F !D
> 
> All of the above. Put in other words: all fields whose final
> representation type could be the size of a pointer if we unpacked
> enough.

Ok, that makes sense. I would include Double# and Int64# in this list. For the simple reason that if the target audience are beginners they will have a hard time figuring out why their programs run 20x faster with Float/Int than with Double/Int64 instead of just 2x faster.

Roman





More information about the Glasgow-haskell-users mailing list