Strictness annotation on unlifted type [GHC-55666]

Flag: -Wredundant-strictness-flags

A strictness annotation (also called a bang: !) can be used to denote that a value should not be evaluated lazily. In some cases this can lead to faster code because fewer heap allocations are required. Here it is used to mark a that a field in a datatype should not be evaluated lazily.

However, values of unlifted types like Int# are strict by definition because they represent an actual value, not a pointer to a potentially unevaluated value (thunk).

Therefore, adding strictness annotations to unlifted types or fields of such types is redundant. They should be omitted to avoid confusion.

Examples

Bang (!) on unlifted type
src/MyLib.hs:16:5: warning: [GHC-55666] [-Wredundant-strictness-flags]
    * Strictness flag has no effect on unlifted type `Int#'
    * In the definition of data constructor `MkT'
      In the data type declaration for `T'
   |
   |   = MkT !Int#
   |     ^^^^^^^
Bang_on_unlifted_type.hs
Before
{-# LANGUAGE MagicHash #-}

module Bang_on_unlifted_type where

import GHC.Base (Int#)

data T = MkT !Int#
After
{-# LANGUAGE MagicHash #-}

module Bang_on_unlifted_type where

import GHC.Base (Int#)

data T = MkT Int#