[GHC] #12872: Pattern synonyms allow multiple type signatures but only use the first

GHC ghc-devs at haskell.org
Wed Nov 23 13:23:44 UTC 2016


#12872: Pattern synonyms allow multiple type signatures but only use the first
-------------------------------------+-------------------------------------
           Reporter:  jophish        |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  GHC accepts
  Unknown/Multiple                   |  invalid program
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 GHC seems to only be using the first signature for pattern synonyms

 GHC 8.0.2 allows this to compile:

 {{{#!hs
 {-# LANGUAGE PatternSynonyms #-}
 module Pattern where

 pattern Foo :: ()
 pattern Foo :: Bool
 pattern Foo = ()
 }}}

 but not this:
 {{{#!hs
 {-# LANGUAGE PatternSynonyms #-}
 module Pattern where

 pattern Foo :: Bool
 pattern Foo :: ()
 pattern Foo = ()
 }}}

 This compiles and ghci tells me the type of `Foo` is `()`:
 {{{#!hs
 {-# LANGUAGE PatternSynonyms #-}
 module Pattern where

 pattern Foo :: ()
 pattern Foo :: Bool
 pattern Foo <- _
   where Foo = undefined
 }}}

 This doesn't compile (as expected):
 {{{#!hs
 {-# LANGUAGE PatternSynonyms #-}
 module Pattern where

 pattern Foo :: ()
 pattern Foo :: Bool Bool
 pattern Foo = ()
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12872>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list