Skip to content

Commit 0cd2229

Browse files
document GHC-55666
1 parent 6a7fb33 commit 0cd2229

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Bang_on_unlifted_type where
2+
3+
import GHC.Base (Int#)
4+
5+
data T = MkT Int#
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Bang_on_unlifted_type where
2+
3+
import GHC.Base (Int#)
4+
5+
data T = MkT !Int#
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
title: Bang (!) on unlifted type
3+
---
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Strictness annotation on unlifted type
3+
summary: Using a strictness annotation (bang) on an unlifted type is redudant as unlifted values are strict by definition
4+
severity: warning
5+
flag: -Wredundant-strictness-flags
6+
introduced: GHC 9.6.1
7+
---
8+
9+
A strictness annotation (also called a bang: `!`) can be used to denote that a type should not be evaluated lazily.
10+
In some cases this can lead to faster code because fewer heap allocation are required.
11+
12+
However, unlifted types like `Int#` are strict by definition because they are a value,
13+
not a pointer to a potentially unevaluated value (thunk).
14+
15+
Therefore, adding strictness annotations to unlifted types or fields of such types are redudant.
16+
They should be omitted to prevent confusion.

0 commit comments

Comments
 (0)