Naïve Haskell data representation

Metadata for values

Function values


Thunk values



Unboxed types

Unboxed types in GHC

Restrictions on unboxed types

seq revisited

Example: seq implementation

Val *seq_2 (Val *a, Val *b)
{ /* assume seq_1 put first arg in a */
val = gc_malloc (offsetof (Val, args[2]));
val->info = &seq_info;
val->args[0] = a->args[0];
val->args[1] = b->args[0];
return val;

struct ValInfo seq_info = {
some_gcinfo, THUNK, .thunk = &seq_thunk

Exception *seq_thunk (Void *c)
Exception *e = force (&c->args[0]);
if (!e) {
c->info = &ind_info; /* ValInfo with tag IND */
c->args[0] = c->args[1]; /* forward to b */
return e;

Strictness revisited

Semantic effects of strictness

case statements revisited

newtype declarations

newtype semantics

newtype semantics

The UNPACK pragma

User-managed memory


More Storable types

malloc and mallocForeignPtr

Working with ForeignPtrs


Lazy ByteStrings

Lazy ByteString implementation