Unpacking polymorphic fields

Takano Akio aljee at hyper.cx
Wed Nov 15 05:55:10 EST 2006


Hi,

Suppose I have the following two datatypes.

data B = B {-# UNPACK #-} !Int
data C a = C {-# UNPACK #-} !Char !a

If I have a strict function:

test :: C B -> IO ()

I want it to be worker-wrapper-transformed into:

$wtest :: Char# -> Int# -> State# RealWorld -> (# State# RealWorld, () #)

but GHC actually generates something like:

$wtest :: Char# -> B -> State# RealWorld -> (# State# RealWorld, () #)

The question is: is there any way to ask GHC to produce the former?
If the field is not polymorphic, UNPACK pragma can be used for this, but
it does not work in this case. If there is no such way, would
it be a reasonable "feature request" to add one?

Regards,
Takano Akio


More information about the Glasgow-haskell-users mailing list