Skip to content

Commit 1504655

Browse files
committed
fixup! Document error GHC-05380
1 parent 5b8250a commit 1504655

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

message-index/messages/GHC-05380/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ constructors, you should use `data` instead of `newtype`.
1010

1111
The reason that you need exactly one constructor is that `newtype` constructors
1212
are removed at runtime.
13-
So during runtime, if you define `newtype Age = Age Int`, `Age` is the same as `Int`.
14-
Only during the compilation phase, will the `Age` and `Int` types be different.
15-
If we allow multiple constructors for a newtype, there would be no way to distinguish them during execution.
13+
For example, if you define `newtype Age = Age Int`, the bits in memory that represent
14+
an `Age` are identical to those that would represent the `Int` in the constructor.
15+
The `Age` and `Int` types are distinguished only at compile time.
16+
If types defined with `newtype` could have multiple constructors, there would be no way to distinguish them during execution.

message-index/messages/GHC-05380/more-than-1-constructor/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ Main.hs:1:1: error: [GHC-05380]
1414
```
1515
## Explanation
1616

17-
A newtype constructor can only have a single constructor. It is not allowed to have multiple
18-
constructors when defining a newtype.
17+
A `newtype` constructor can only have a single constructor.
18+
It is not allowed to have multiple constructors when defining a `newtype`.

message-index/messages/GHC-05380/zero-constructors/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Main.hs:1:1: error: [GHC-05380]
1414

1515
## Explanation
1616

17-
A `newtype` constructor does need to have a single constructor. It is not allowed to
18-
have a newtype without a constructor. It is allowed to have a `data` type without a
19-
constructor, so in order to fix this, you need to come up with a constructor for the newtype
20-
or change the `newtype` keyword to a `data` keyword.
17+
A `newtype` definition is required to have exactly one constructor, so constructorless `newtype`s are not allowed.
18+
Datatypes defined using `data` are allowed to be constructorless,
19+
so this problem can be fixed either by adding a constructor to the `newtype`
20+
or by changing the `newtype` keyword to a `data` keyword.

0 commit comments

Comments
 (0)