Records in Haskell

Simon Peyton-Jones simonpj at
Mon Jan 16 10:46:36 CET 2012

| > But note what has happened: we have simply re-invented SORF.  So the
| > conclusion is this:
| >
| >   the only sensible way to implement FDR is using SORF.
| An obvious question at this point: can records have unboxed fields?
| I'm worried a bit about the kinds that can appear in a has constraint:

Oh yes!  That is indeed an important question, and one I had neglected.  

All of GHC's abstraction mechanisms only work over *lifted* types (which are all boxed).  They don't work for unlifted types (many of which are unboxed, and vary in width).

So SORF won't work at all for records with unboxed fields, such as
	data T = MkT { f :: Int# }
But it *will* work for records with boxed fields with an UNPACK pragma
	data T = MKT { f :: {-# UNPACK #-} Int }

I think it's probably an acceptable restriction, but we'd better be aware of it.

With FDR (where you can't *abstract* over these constraints) we might be able to allow unboxed field, via some unsavoury ad-hoc cases for Has constraints.  But I don't like it.

I'll add this to the SORF wiki page.


More information about the Glasgow-haskell-users mailing list