[GHC] #4940: Bad error message using poly pat bind with MonoPatBinds

GHC cvs-ghc at haskell.org
Tue Feb 1 11:02:34 CET 2011


#4940: Bad error message using poly pat bind with MonoPatBinds
---------------------------------+------------------------------------------
    Reporter:  batterseapower    |       Owner:                                   
        Type:  feature request   |      Status:  new                              
    Priority:  normal            |   Component:  Compiler (Type checker)          
     Version:  7.0.1             |    Keywords:                                   
    Testcase:                    |   Blockedby:                                   
          Os:  Unknown/Multiple  |    Blocking:                                   
Architecture:  Unknown/Multiple  |     Failure:  Incorrect warning at compile-time
---------------------------------+------------------------------------------
 This program:

 {{{
 foo :: a -> a
 bar :: a -> a
 (foo, bar) = (\x -> x, \y -> y)

 main = print $ foo $ bar 1
 }}}

 Is trying to pattern-bind a polymorphic function. The error message is
 dreadful:

 {{{
 /Users/mbolingbroke/Junk/PolyPatBinds.hs:5:15:
     Couldn't match expected type `t -> t1'
                 with actual type `forall a. a -> a'
     The lambda expression `\ x -> x' has one argument one argument,
     but its type `forall a. a -> a' has none
     In the expression: \ x -> x
     In the expression: (\ x -> x, \ y -> y)
 }}}

 The issues are:

 1. It repeats itself: "one argument one argument"
 2. It is patently incorrect: the type forall a. a -> a DOES have one
 argument in the standard nomenclature
 3. It does not point the user towards the fix (-XNoMonoPatBinds)

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



More information about the Glasgow-haskell-bugs mailing list