[GHC] #10873: Bad error message for incorrect pattern synonym signature

#10873: Bad error message for incorrect pattern synonym signature -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 (Type checker) | Keywords: newcomer | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- Consider the following program {{{ {-# LANGUAGE PatternSynonyms #-} pattern Pat :: Show a => () => a -> Maybe a pattern Pat a = Just a }}} GHC complains that {{{ test.hs:4:9: No instance for (Show a) arising from a pattern }}} I think this is quite difficult to understand. The problem is that matching on `Just a` doesn't provide the show constraint (it provides no constraints). A better error message here would explain this fact and maybe a short explanation of the difference between prov/req in a pattern synonym signature. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10873 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10873: Bad error message for incorrect pattern synonym signature -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.2 checker) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): Ich. Agreed that the error message is terrible. Also agreed with your analysis of this (confusing) situation. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10873#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10873: Bad error message for incorrect pattern synonym signature -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.2 checker) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): -------------------------------------+------------------------------------- Comment (by mpickering): Another note: there is another bad error message when there is an arity mismatch. Seems like some contexts need to be sprinkled in relevant places. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10873#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10873: Bad error message for incorrect pattern synonym signature -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.2 checker) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ak3n): Is it okay that GHC (master head) compiles it without problems now? Build of fork with test: https://travis-ci.org/ak3n/ghc/jobs/98938720 Commit: https://github.com/ak3n/ghc/commit/aee63f611b30164cc1c828a66d22e6e7302af385 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10873#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10873: Bad error message for incorrect pattern synonym signature -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.2 checker) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): The error should now be triggered by switching around the constraints. {{{ {-# LANGUAGE PatternSynonyms #-} pattern Pat :: () => Show a => a -> Maybe a pattern Pat a = Just a }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10873#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10873: Bad error message for incorrect pattern synonym signature -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.2 checker) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): I just tried this with a recent version of HEAD and there is still the same bad error. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10873#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10873: Bad error message for incorrect pattern synonym signature -------------------------------------+------------------------------------- Reporter: mpickering | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.2 checker) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by mpickering: Old description:
Consider the following program
{{{ {-# LANGUAGE PatternSynonyms #-}
pattern Pat :: Show a => () => a -> Maybe a pattern Pat a = Just a }}}
GHC complains that
{{{ test.hs:4:9: No instance for (Show a) arising from a pattern }}}
I think this is quite difficult to understand. The problem is that matching on `Just a` doesn't provide the show constraint (it provides no constraints). A better error message here would explain this fact and maybe a short explanation of the difference between prov/req in a pattern synonym signature.
New description: Consider the following program {{{ {-# LANGUAGE PatternSynonyms #-} pattern Pat :: () => Show a => a -> Maybe a pattern Pat a = Just a }}} GHC complains that {{{ test.hs:4:9: No instance for (Show a) arising from a pattern }}} I think this is quite difficult to understand. The problem is that matching on `Just a` doesn't provide the show constraint (it provides no constraints). A better error message here would explain this fact and maybe a short explanation of the difference between prov/req in a pattern synonym signature. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10873#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10873: Bad error message for incorrect pattern synonym signature -------------------------------------+------------------------------------- Reporter: mpickering | Owner: rdragon Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.2 checker) | Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by rdragon): * owner: => rdragon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10873#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10873: Bad error message for incorrect pattern synonym signature -------------------------------------+------------------------------------- Reporter: mpickering | Owner: rdragon Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.2 checker) | Keywords: Resolution: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: newcomer => PatternSynonyms -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10873#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10873: Bad error message for incorrect pattern synonym signature -------------------------------------+------------------------------------- Reporter: mpickering | Owner: rdragon Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.2 checker) | Keywords: Resolution: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1866 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * differential: => Phab:D1866 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10873#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10873: Bad error message for incorrect pattern synonym signature
-------------------------------------+-------------------------------------
Reporter: mpickering | Owner: rdragon
Type: bug | Status: new
Priority: normal | Milestone: 8.0.1
Component: Compiler (Type | Version: 7.10.2
checker) | Keywords:
Resolution: | PatternSynonyms
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1866
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10873: Bad error message for incorrect pattern synonym signature -------------------------------------+------------------------------------- Reporter: mpickering | Owner: rdragon Type: bug | Status: closed Priority: normal | Milestone: 8.0.1 Component: Compiler (Type | Version: 7.10.2 checker) | Keywords: Resolution: fixed | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1866 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed Comment: This is greatly improved with the patch in comment:10. The original example now fails with, {{{ Hi.hs:6:22: error: • No instance for (Show a) arising from the "provided" constraints claimed by the signature of ‘Pat’ In other words, a successful match on the pattern Just a does not provide the constraint (Show a) • In the declaration for pattern synonym ‘Pat’ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10873#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC