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

GHC ghc-devs at haskell.org
Sun Dec 27 18:00:10 UTC 2015


#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


More information about the ghc-tickets mailing list