Unpacking polymorphic fields

Takano Akio aljee at hyper.cx
Wed Nov 15 06:09:18 EST 2006


On Wed, 15 Nov 2006 10:58:23 +0000
Simon Peyton-Jones <simonpj at microsoft.com> wrote:

> Can you send a small example program for 'test'?

Here's an example:

module Test(test) where

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

printB :: B -> IO ()
printB (B x) = print x

test :: C B -> IO ()
test (C c b) = print c >> printB b


More information about the Glasgow-haskell-users mailing list