#3592: Eta-contraction gives a rather bogus type error message
-------------------------+--------------------------------------------------
    Reporter:  guest     |        Owner:         
        Type:  bug       |       Status:  new    
    Priority:  normal    |    Milestone:         
   Component:  Compiler  |      Version:  6.10.3 
    Severity:  normal    |   Resolution:         
    Keywords:            |   Difficulty:  Unknown
    Testcase:            |           Os:  MacOS X
Architecture:  x86       |  
-------------------------+--------------------------------------------------
Changes (by simonpj):

  * difficulty:  => Unknown
  * summary:  ghc: panic! on overloaded type synonym => Eta-contraction
              gives a rather bogus type error message

Comment:

 With the HEAD (and I think 6.12) we get
 {{{
 T3592.hs:7:4:
     Could not deduce (Show (T a)) from the context ()
       arising from a use of `show' at T3592.hs:7:4-7
     Possible fix:
       add (Show (T a)) to the context of the type signature for `f'
       or add an instance declaration for (Show (T a))
     In the expression: show
     In the definition of `f': f = show
 }}}
 which at least is not a crash. So that has already been fixed.

 Your type signature means this
 {{{
 f :: forall a. (Show a => a) -> String
 }}}
 If we eta-expand the definition of f to
 {{{
 f x = show x
 }}}
 then we get the totally reasonable error message:
 {{{
 T3592.hs:7:11:
     Could not deduce (Show a) from the context ()
       arising from a use of `x' at T3592.hs:7:11
     Possible fix:
       add (Show a) to the context of the type signature for `f'
     In the first argument of `show', namely `x'
     In the expression: show x
     In the definition of `f': f x = show x
 }}}
 I think we should get the same error from the eta-contracted version, so
 I'm going to re-title this bug report, and put it in my list for the type
 inference overhaul.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3592#comment:1>
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