
On Mon, Jul 31, 2017 at 11:44:20PM +0200, Nick Smallbone wrote:
Tom Ellis
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.
* The field must be strict (this is because otherwise, UNPACKing changes the semantics of the data type you are declaring by making it more strict)
That makes sense.
* 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. Tom