
26 Feb
2009
26 Feb
'09
5:48 a.m.
On 26 Feb 2009, at 11:42, Erik de Castro Lopo wrote:
Hi all,
I'm looking at some code that defines a record:
data Position = Position { posOffset :: {-# UNPACK #-} !Int , posRow :: {-# UNPACK #-} !Int , posColumn :: {-# UNPACK #-} !Int }
What does the the exclamation mark mean? And UNPACK?
The ! means "strict" – i.e. don't store a thunk for an Int here, but evaluate it first. The {-# UNPACK #-} tells the compiler that it can unpack the Int – meaning that a Position will be neatly packed into 12 bytes. Bob