[GHC] #919: Cryptic type error message (should be syntax error)

GHC trac at galois.com
Mon Oct 2 14:10:48 EDT 2006


#919: Cryptic type error message (should be syntax error)
---------------------------------------------+------------------------------
    Reporter:  josef.svenningsson at gmail.com  |        Owner:         
        Type:  bug                           |       Status:  new    
    Priority:  normal                        |    Milestone:         
   Component:  Compiler                      |      Version:  6.5    
    Severity:  normal                        |     Keywords:         
          Os:  Unknown                       |   Difficulty:  Unknown
Architecture:  Unknown                       |  
---------------------------------------------+------------------------------
It seems ghc allows a syntax for types which if beyond Haskell98 even
 without -fglasgow-exts. Consider the following program:

 {{{
 destroy :: (forall a. (a -> Maybe (b,a)) -> a -> c) -> [b] -> c
 destroy g xs = g listpsi xs
   where listpsi :: [a] -> Maybe (a,[a])
         listpsi [] = Nothing
         listpsi (x:xs) = Just (x,xs)
 }}}


 It gives the following rather cryptic error message without -fglasgow-
 exts:

 {{{
 ConcatMap.hs:7:17:
     Couldn't match expected type `.' (a rigid variable)
            against inferred type `(->)'
       `.' is bound by the type signature for `destroy'
         at ConcatMap.hs:6:20
     Probable cause: `listpsi' is applied to too few arguments
     In the first argument of `g', namely `listpsi'
     In the expression: g listpsi xs
 }}}

 The fact that ghc interpreted `.' as a type variable baffeled me for a
 moment. I would expect ghc to report a syntax error since the type is not
 syntactically Haskell98.

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


More information about the Glasgow-haskell-bugs mailing list