[GHC] #9954: Required constraints are not inferred for pattern synonyms involving GADTs

GHC ghc-devs at haskell.org
Sat Jan 3 22:31:27 UTC 2015


#9954: Required constraints are not inferred for pattern synonyms involving GADTs
-------------------------------------+-------------------------------------
        Reporter:  cactus            |                   Owner:  cactus
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler (Type    |                 Version:
  checker)                           |                Keywords:
      Resolution:                    |  PatternSynonyms
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:  #9953             |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by simonpj):

 This looks absolutely correct to me.  Try it with an ordinary function,
 without the synonym:
 {{{
 boo :: T a -> Bool
 boo (MkT2 (f -> x)) = True
 }}}
 and you get
 {{{
 T9954.hs:12:12:
     Could not deduce (Eq a1) arising from a use of `f'
     from the context a ~ Maybe a1
       bound by a pattern with constructor:
                  MkT2 :: forall a. a -> T (Maybe a),
                in an equation for `boo'
       at T9954.hs:12:6-18
     Possible fix:
       add (Eq a1) to the context of the data constructor `MkT2'
     In the expression: f
     In the pattern: f -> x
     In the pattern: MkT2 (f -> x)
 }}}
 And indeed, from where can we conjure up equality on the existentially-
 bound type?

 So to me this looks like precisely the correct behaviour.

 Siimon

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


More information about the ghc-tickets mailing list