From 7de6d28f368c4748e7fe5b08df62c9d1cf118c99 Mon Sep 17 00:00:00 2001 From: Jaro Date: Sun, 4 Aug 2024 08:56:15 +0000 Subject: [PATCH] Basic explanation of 59692 --- .../messages/GHC-59692/example1/after/Example1.hs | 6 ++++++ .../GHC-59692/example1/before/Example1.hs | 9 +++++++++ .../messages/GHC-59692/example1/index.md | 15 +++++++++++++++ message-index/messages/GHC-59692/index.md | 10 ++++++++++ 4 files changed, 40 insertions(+) create mode 100644 message-index/messages/GHC-59692/example1/after/Example1.hs create mode 100644 message-index/messages/GHC-59692/example1/before/Example1.hs create mode 100644 message-index/messages/GHC-59692/example1/index.md create mode 100644 message-index/messages/GHC-59692/index.md diff --git a/message-index/messages/GHC-59692/example1/after/Example1.hs b/message-index/messages/GHC-59692/example1/after/Example1.hs new file mode 100644 index 00000000..ee2da06a --- /dev/null +++ b/message-index/messages/GHC-59692/example1/after/Example1.hs @@ -0,0 +1,6 @@ +module Example1 where + +data T a + +instance Eq a => Eq (T a) where + (==) = (==) diff --git a/message-index/messages/GHC-59692/example1/before/Example1.hs b/message-index/messages/GHC-59692/example1/before/Example1.hs new file mode 100644 index 00000000..0dd82030 --- /dev/null +++ b/message-index/messages/GHC-59692/example1/before/Example1.hs @@ -0,0 +1,9 @@ +module Example1 where + +data T a + +instance Eq a => Eq (T a) where + (==) = (==) + +instance Show a => Eq (T a) where + (==) = (==) diff --git a/message-index/messages/GHC-59692/example1/index.md b/message-index/messages/GHC-59692/example1/index.md new file mode 100644 index 00000000..d36d808c --- /dev/null +++ b/message-index/messages/GHC-59692/example1/index.md @@ -0,0 +1,15 @@ +Even though the instances have different constraints, they are still considered the same. + +## Error message + +``` +messages/GHC-59692/example1/before/Example1.hs:3:10: error: [GHC-59692] + Duplicate instance declarations: + instance Eq a => Eq (T a) + -- Defined at messages/GHC-59692/example1/before/Example1.hs:3:10 + instance Show a => Eq (T a) + -- Defined at messages/GHC-59692/example1/before/Example1.hs:6:10 + | +3 | instance Eq a => Eq (T a) where + | ^^^^^^^^^^^^^^^^ +``` diff --git a/message-index/messages/GHC-59692/index.md b/message-index/messages/GHC-59692/index.md new file mode 100644 index 00000000..3d68f5d5 --- /dev/null +++ b/message-index/messages/GHC-59692/index.md @@ -0,0 +1,10 @@ +--- +title: Duplicate instance declarations +summary: An instance has been defined twice for the same type. +introduced: 9.6.1 +severity: error +--- + +You can only define a single instance for every type, because it must be possible to automatically resolve class constraints without any ambiguity. +Note that instances are considered the same even if they have different constraints. Only the arguments of the class are considered when matching instances. +See the [GHC User Guide](https://downloads.haskell.org/~ghc/9.10.1/docs/users_guide/exts/instances.html) for more information on instance declarations and resolution.