[GHC] #7766: equality constraints exposed by patterns mess up constraint inference

GHC cvs-ghc at haskell.org
Wed Mar 13 14:00:31 CET 2013


#7766: equality constraints exposed by patterns mess up constraint inference
----------------------------------------+-----------------------------------
  Reporter:  heisenbug                  |          Owner:                  
      Type:  bug                        |         Status:  closed          
  Priority:  normal                     |      Milestone:                  
 Component:  Compiler                   |        Version:  7.7             
Resolution:  invalid                    |       Keywords:                  
        Os:  Unknown/Multiple           |   Architecture:  Unknown/Multiple
   Failure:  GHC rejects valid program  |     Difficulty:  Unknown         
  Testcase:                             |      Blockedby:                  
  Blocking:                             |        Related:                  
----------------------------------------+-----------------------------------
Changes (by simonpj):

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


Comment:

 This is by design.   Type inference in the presence of GADTs is tricky!

 If you give the signature `main :: IO ()` it works fine.  But here you are
 asking GHC to ''infer'' the type of `main`.  (Remember, Haskell doesn't
 insist on `IO ()`; the `main` function can have type `IO Char`.)

 Becuase you are pattern matching against GADTs there are equalities in
 scope, so GHC declines to contrain the type of `main`.  In this particular
 case there is only one answer, but that's very hard to figure out, so we
 fail conservatively.

 Bottom line: use type signatures when pattern matching on GADTs.

 Simon

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



More information about the ghc-tickets mailing list