Polymorphic strict fields

Iavor Diatchki iavor.diatchki at gmail.com
Mon Apr 30 22:47:55 EDT 2007


Hello,

At present, the Haskell report specifies the semantics of strict
datatype fields (the ones marked with !) in terms of the strict
application operator $! [Section 4.2.1, paragraph "Strictness flags"].
 However, if we were to add polymorphic fields to Haskell, then we
cannot use this definition anymore because the application operator
(or ``seq`` for that matter) does not have the correct type---we would
need many rank-2 versions, one for each possible type scheme.

Notice, furthermore, that the behavior of such constructors may be a
bit unexpected when combined with overloading.  Consider, for example,
the following declarations:

> data T = T !(forall a. Eq a => a)
> test = seq (T undefined) True

In GHC 6.6 ``test`` evaluets to ``True`` because ``undefined`` is
converted to a function that expects its implict evidence argument.
Hugs does not support strictness annotations on polymorphic fields (I
thought that this was a bug but, perhaps, it was a delibarate choice?)

It seems that even without overloading, we may think of polymorphic
values as being parameterized by their type arguments, so that they
are always in head-normal form.

All of this leads me to think that perhaps we should not allow
strictness annotations on polymorphic fields.  Would people find this
too restrictive? If so, does anoyone have ideas about what should
happen and how to specify the behavior?

-Iavor


More information about the Haskell-prime mailing list