[Haskell-cafe] What can be UNPACK'ed?
Brandon Allbery
allbery.b at gmail.com
Mon Jul 31 22:12:28 UTC 2017
On Mon, Jul 31, 2017 at 5:58 PM, Tom Ellis <
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote:
> On Mon, Jul 31, 2017 at 11:44:20PM +0200, Nick Smallbone wrote:
> > Tom Ellis <tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> writes:
> > > Thanks, that's helpful info, but what I'm really after is a definitive
> > > condition under which fields can be UNPACK'ed. The docs are very
> vague:
> > >
> > > https://downloads.haskell.org/~ghc/7.0.2/docs/html/users_
> guide/pragmas.html
> >
> > As far as I know, the restrictions for UNPACKing a field are as follows:
>
> Ah, very nice, thanks Nick.
I think this might be in the Commentary somewhere, as I've seen essentially
that list.
> * The type must not be just a type variable
> > (i.e., the constructor must be known at compile time)
>
> Eventually I'd like to see if we can relax this condition but first ...
>
> > * The field's type must have only one constructor
>
> Do you know the rationale for this? It seems like there should be no
> problem unpacking a constructor tag plus payload, even if the payload size
> varies, as long as the maximum payload size in known.
UNPACK means unbox, and the constructor tag is part of the box. I suspect
something (gc?) assumes that a constructor tag is always the first thing in
a memory chunk, so having a constructor tag unpacked into the middle of
something else causes problems (e.g. it will try to gc the middle of the
containing memory object).
--
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170731/acb3c218/attachment.html>
More information about the Haskell-Cafe
mailing list