-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
message-index/messages/GHC-10498/function-arguments/after/Lib.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Lib where | ||
|
||
areDifferent :: Eq a => a -> a -> Maybe (a, a) | ||
areDifferent x y | ||
| x == y = Nothing | ||
areDifferent x y = Just (x, y) |
5 changes: 5 additions & 0 deletions
5
message-index/messages/GHC-10498/function-arguments/before/Lib.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Lib where | ||
|
||
areDifferent :: a -> a -> Maybe (a, a) | ||
areDifferent x x = Nothing | ||
areDifferent x y = Just (x, y) |
25 changes: 25 additions & 0 deletions
25
message-index/messages/GHC-10498/function-arguments/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: Duplicate function arguments | ||
--- | ||
|
||
``` | ||
Lib.hs:4:14: error: [GHC-10498] | ||
• Conflicting definitions for ‘x’ | ||
Bound at: Lib.hs:4:14 | ||
Lib.hs:4:16 | ||
• In an equation for ‘areDifferent’ | ||
| | ||
4 | areDifferent x x = Nothing | ||
| | ||
``` | ||
|
||
*Advanced topic:* somewhat surprisingly, you are allowed | ||
to duplicate arguments of type-level functions as in | ||
|
||
```haskell | ||
{-# LANGUAGE DataKinds, TypeFamilies #-} | ||
type family IsElem x xs where | ||
IsElem _ '[] = 'False | ||
IsElem x (x ': xs) = 'True | ||
IsElem x (_ ': xs) = IsElem x xs | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
title: Conflicting definitions | ||
summary: The same entity has more than one definition | ||
severity: error | ||
introduced: 9.6.1 | ||
--- | ||
|
||
GHC does not allow the same entity to have more than one | ||
definitions. In some contexts it can figure out which one | ||
supposed to shadow another: local definitions take | ||
priority over global definitions, etc. Shadowing is just a warning, GHC-63397. However, if the definitions are on the same | ||
level it becomes a fatal error. |
3 changes: 3 additions & 0 deletions
3
message-index/messages/GHC-10498/type-parameters/after/Lib.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Lib where | ||
|
||
data Pair a = Pair a a |
3 changes: 3 additions & 0 deletions
3
message-index/messages/GHC-10498/type-parameters/before/Lib.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Lib where | ||
|
||
data Pair a a = Pair a a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: Duplicate datatype parameters | ||
--- | ||
|
||
``` | ||
Lib.hs:3:11: error: [GHC-10498] | ||
Conflicting definitions for ‘a’ | ||
Bound at: Lib.hs:3:11 | ||
Lib.hs:3:13 | ||
| | ||
3 | data Pair a a = Pair a a | ||
| | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Lib where | ||
|
||
function :: Int -> Int | ||
function 1 = 1 | ||
function 2 = 2 | ||
function 3 = 3 | ||
function _ = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Lib where | ||
|
||
function :: Int -> Int | ||
function 1 = 1 | ||
function 2 = 2 | ||
functlon 3 = 3 | ||
function _ = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
title: Just a typo | ||
--- | ||
|
||
``` | ||
Lib.hs:7:1: error: [GHC-29916] | ||
Multiple declarations of ‘function’ | ||
Declared at: Lib.hs:4:1 | ||
Lib.hs:7:1 | ||
| | ||
7 | function _ = 4 | ||
| | ||
``` | ||
|
||
Because of a typo (`functlon` instead of `function`) | ||
GHC parses the third equation as a definition of | ||
`functlon` (without a type signature), while the fourth | ||
equation becomes the second, conflicting definition of `function`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
|
||
module Lib where | ||
|
||
data Foo = Foo { x :: Int, y :: Int } | ||
|
||
foo :: Foo -> Int -> Int | ||
foo Foo{y} x = x + y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{-# LANGUAGE RecordWildCards #-} | ||
|
||
module Lib where | ||
|
||
data Foo = Foo { x :: Int, y :: Int } | ||
|
||
foo :: Foo -> Int -> Int | ||
foo Foo{..} x = x + y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: Implicit duplication because of `RecordWildCards` | ||
--- | ||
|
||
``` | ||
Lib.hs:8:9: error: [GHC-10498] | ||
• Conflicting definitions for ‘x’ | ||
Bound at: Lib.hs:8:9-10 | ||
Lib.hs:8:13 | ||
• In an equation for ‘foo’ | ||
| | ||
8 | foo Foo{..} x = x + y | ||
| | ||
``` | ||
|
||
Consider using `NamedFieldPuns` to be more explicit | ||
about which variables are bound where. |