Unpack primitive types by default in data
johan.tibell at gmail.com
Fri Feb 17 18:51:14 CET 2012
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
Note that the user only needs to understand when unpacking happens if
he/she wants to reason about whether a given strict field will be
automatically unpacked. When in doubt he/she can always use an
explicit UNPACK or NOUNPACK. We're trying to make the default case
more sane, not remove control.
More information about the Glasgow-haskell-users