
On Thu, Feb 26, 2009 at 8:07 AM, Colin Paul Adams
"Thomas" == Thomas Davie
writes: Thomas> The {-# UNPACK #-} tells the compiler that it can unpack Thomas> the Int – meaning that a Position will be neatly packed Thomas> into 12 bytes.
What would be the difference if there was no UNPACK pragma?
For example, if you write valid :: Position -> Bool valid (Position o r c) = o < r && c < 80 It is just an example, not necessarily meaningful :). If you use the UNPACK pragmas, then internally the compiler will create something like valid :: Int# -> Int# -> Int# -> Bool valid o r c = o <# r && c <# 80 Basically the three integers will be passed on registers. Without the UNPACK, they would be passed on the heap. Without the strictness annotation, a pointer on the heap would be passed to them (i.e. a pointer on the register would point to the Position structure which would have a pointer to the integer, not very nice). HTH, PS: I'm not sure if the unboxed operations I wrote are correct, but you get the idea :). -- Felipe.