Skip to content

Semantics of strictness flags on constructor arguments of non * kind

Summary

The Haskell 2010 report specifies:

Strictness Flags Whenever a data constructor is applied, each argument to the constructor is evaluated if and only if the corresponding type in the algebraic datatype declaration has a strictness flag, denoted by an exclamation point, “!”. Lexically, “!” is an ordinary varsym not a reservedop; it has special significance only in the context of the argument types of a data declaration.

https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-710004.2.1

But in GHC we can define constructors that take arguments that are not of kind * (or Type), e.g.:

{-# LANGUAGE MagicHash #-}
import GHC.Exts
data Test = Test !Int#

What does the ! do in this case? Is it simply ignored? Maybe GHC should reject this program or show a warning, but it should at least be documented somewhere.

Environment

  • GHC version used (if appropriate): 8.10.4
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information