File tree Expand file tree Collapse file tree 13 files changed +133
-0
lines changed
message-index/messages/GHC-10498 Expand file tree Collapse file tree 13 files changed +133
-0
lines changed Original file line number Diff line number Diff line change 1+ module Lib where
2+
3+ areDifferent :: Eq a => a -> a -> Maybe (a , a )
4+ areDifferent x y
5+ | x == y = Nothing
6+ areDifferent x y = Just (x, y)
Original file line number Diff line number Diff line change 1+ module Lib where
2+
3+ areDifferent :: a -> a -> Maybe (a , a )
4+ areDifferent x x = Nothing
5+ areDifferent x y = Just (x, y)
Original file line number Diff line number Diff line change 1+ ---
2+ title : Duplicate function arguments
3+ ---
4+
5+ ```
6+ Lib.hs:4:14: error: [GHC-10498]
7+ • Conflicting definitions for ‘x’
8+ Bound at: Lib.hs:4:14
9+ Lib.hs:4:16
10+ • In an equation for ‘areDifferent’
11+ |
12+ 4 | areDifferent x x = Nothing
13+ |
14+ ```
15+
16+ * Advanced topic:* somewhat surprisingly, you are allowed
17+ to duplicate arguments of type-level functions as in
18+
19+ ``` haskell
20+ {-# LANGUAGE DataKinds, TypeFamilies #-}
21+ type family IsElem x xs where
22+ IsElem _ '[] = 'False
23+ IsElem x (x ': xs ) = 'True
24+ IsElem x (_ ': xs ) = IsElem x xs
25+ ```
Original file line number Diff line number Diff line change 1+ ---
2+ title : Conflicting definitions
3+ summary : The same entity has more than one definition
4+ severity : error
5+ introduced : 9.8.1
6+ ---
7+
8+ GHC does not allow the same entity to have more than one
9+ definition. In some contexts it can figure out which one
10+ is supposed to shadow another: local definitions take
11+ priority over global definitions, etc. Shadowing is just
12+ a warning, GHC-63397. However, if the definitions are on the same
13+ level it becomes a fatal error.
Original file line number Diff line number Diff line change 1+ module Lib where
2+
3+ data Pair a = Pair a a
Original file line number Diff line number Diff line change 1+ module Lib where
2+
3+ data Pair a a = Pair a a
Original file line number Diff line number Diff line change 1+ ---
2+ title : Duplicate datatype parameters
3+ ---
4+
5+ ```
6+ Lib.hs:3:11: error: [GHC-10498]
7+ Conflicting definitions for ‘a’
8+ Bound at: Lib.hs:3:11
9+ Lib.hs:3:13
10+ |
11+ 3 | data Pair a a = Pair a a
12+ |
13+ ```
Original file line number Diff line number Diff line change 1+ module Lib where
2+
3+ function :: Int -> Int
4+ function 1 = 1
5+ function 2 = 2
6+ function 3 = 3
7+ function _ = 4
Original file line number Diff line number Diff line change 1+ module Lib where
2+
3+ function :: Int -> Int
4+ function 1 = 1
5+ function 2 = 2
6+ functlon 3 = 3
7+ function _ = 4
Original file line number Diff line number Diff line change 1+ ---
2+ title : Just a typo
3+ ---
4+
5+ ```
6+ Lib.hs:7:1: error: [GHC-29916]
7+ Multiple declarations of ‘function’
8+ Declared at: Lib.hs:4:1
9+ Lib.hs:7:1
10+ |
11+ 7 | function _ = 4
12+ |
13+ ```
14+
15+ Because of a typo (` functlon ` instead of ` function ` )
16+ GHC parses the third equation as a definition of
17+ ` functlon ` (without a type signature), while the fourth
18+ equation becomes a separate, conflicting definition of ` function ` .
You can’t perform that action at this time.
0 commit comments