
Hello, What is the interaction between the UNPACK pragma and modules? I've attached a small test case where a datatype is unpacked when it and its associated functions are defined in the same file in which they are used, but it is not unpacked if the definitions are given in another module. There are two versions of the data type, a monomorphic one, defined by:
data Vec3 = Vec3 Double Double Double
and a polymorphic, recursive one, defined by
data C a b = C a b
With the following typedef to make them equivalent
type Vec3 = C Double (C Double (C Double () ))
In the actual file, they're both appropriately annotated with bangs and UNPACK pragmas. The mono datatype is successfully unpacked in both cases, when it is defined in the same file and in a different file. The poly datatype is only unpacked when it is defined in the same file. To see the behavior, compile the attached files with -DMONO_SAME, -DMONO_OTHER, -DPOLY_SAME and -DPOLY_OTHER. In all cases except POLY_OTHER, the program runs in constant space, and in time that is quite competitive with C. (Nice work guys!) However, for POLY_OTHER you will likely have to kill it. The only other flag I used is -O2. Please let me know there's something I'm missing here. Is there a reason why this data type cannot be unboxed across modules? Or is this a bug? Thanks, Scott PS: Also, when the INLINE pragma is used with the Storable instance for the polymorphic data type, it causes heap explosion, even in the same file. Any thoughts here?