#3440: Improve error message for GADT failures
--------------------------------------+-------------------------------------
  Reporter:  simonpj                  |          Owner:                  
      Type:  bug                      |         Status:  new             
  Priority:  normal                   |      Milestone:  6.12.1          
 Component:  Compiler (Type checker)  |        Version:  6.10.4          
  Severity:  normal                   |       Keywords:                  
Difficulty:  Unknown                  |       Testcase:                  
        Os:  Unknown/Multiple         |   Architecture:  Unknown/Multiple
--------------------------------------+-------------------------------------
 If you write
 {{{
  type family Fam a :: *

  data GADT :: * -> * where
    GADT :: a -> Fam a -> GADT (Fam a)

  unwrap :: GADT (Fam a) -> (a, Fam a)
  unwrap (GADT x y) = (x, y)
 }}}
 then typechecking `unwrap` should certainly fail. And it does, but with a
 horrible message:
 {{{
  Main.hs:9:21:
    Couldn't match expected type `a' against inferred type `a1'
      `a' is a rigid type variable bound by
          the type signature for `unwrap' at Main.hs:8:20
      `a1' is a rigid type variable bound by
           the constructor `GADT' at Main.hs:9:8
    In the expression: x
    In the expression: (x, y)
    In the definition of `unwrap': unwrap (GADT x y) = (x, y)
 }}}
 It would be better to say something more like:
 {{{
         Cannot deduce (a ~ a1) from (Fam a ~ Fam a1)
 }}}
 See the thread at
 [http://thread.gmane.org/gmane.comp.lang.haskell.cafe/62322]

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3440>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to