# The size of things

**Jan-Willem Maessen
**
jmaessen@mit.edu

*Fri, 15 Feb 2002 11:40:08 -0500*

>* Yes, I see. Would it be possible to have a standard strict list,
*>* i.e. something equivalent of
*>*
*>* data SList a = SNil | SCons !a SList
*>*
*>* (which could be a member of the same class as the normal lists, and
*>* have the usual functions (length, ++, isPrefixOf...) overloaded)?
*
Unfortuantely, as I understand it the -funbox-strict-fields
optimization doesn't apply to polymorphic fields. That is, you get
the optimization for:
>* data SIntList = SINil | SICons !Int SIntList
*
but not for
>* type SListOfInt = SList Int
*
This is because "SList a" must have a uniform representation for every
possible a, and the Ints must therefore be boxed. You could verify my
instincts by trying this with your example and looking at the space
usage...
If "strict cons" is what's desired, than it shouldn't be hard to add
it as a function and keep lists the way they are. It sounds like
what's really wanted is an "unboxed list" class structure similar to
the hierarchy of unboxed arrays. That's quite a bit more
complicated.
-Jan-Willem Maessen