[GHC] #1901: 6.8.1 incorrectly infers contexts from pattern matches.

GHC trac at galois.com
Fri Nov 16 03:04:05 EST 2007


#1901: 6.8.1 incorrectly infers contexts from pattern matches.
----------------------+-----------------------------------------------------
 Reporter:  guest     |          Owner:         
     Type:  bug       |         Status:  closed 
 Priority:  normal    |      Milestone:         
Component:  Compiler  |        Version:  6.8.1  
 Severity:  normal    |     Resolution:  invalid
 Keywords:            |     Difficulty:  Unknown
 Testcase:            |   Architecture:  Unknown
       Os:  Unknown   |  
----------------------+-----------------------------------------------------
Changes (by simonpj):

  * status:  new => closed
  * difficulty:  => Unknown
  * resolution:  => invalid

Comment:

 It's right for this program to be accepted.  `Foo''` uses a GHC extension,
 namely contexts on individual data constructors, which is syntactic sugar
 for the GADT-style declaration.  It's not Haskell 98.

 If you instead use the Haskell 98 type `Foo'`, and try this
 {{{
 fun :: Foo' t -> t
 fun (MkFoo' a) = a+1
 }}}
 you get the Haskell 98 behaviour.
 {{{
 Foo.hs:6:5:
     Could not deduce (Num t) from the context ()
       arising from a use of `MkFoo'' at Foo.hs:6:5-12
     Possible fix:
       add (Num t) to the context of the type signature for `fun'
     In the pattern: MkFoo' a
     In the definition of `fun': fun (MkFoo' a) = a + 1
 }}}
 I'll improve the user manual.

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


More information about the Glasgow-haskell-bugs mailing list