[GHC] #9173: Better type error messages

GHC ghc-devs at haskell.org
Fri Sep 25 04:56:00 UTC 2015


#9173: Better type error messages
-------------------------------------+-------------------------------------
        Reporter:  simonpj           |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.8.2
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by rwbarton):

 The error there would not be about the type of `foo`, though. It would be
 about the type of `"Howdy!"`.
 {{{
 Foo.hs:4:7:
     Couldn't match expected type ‘Int’ with actual type ‘[Char]’
     In the expression: "Howdy!"
     In an equation for ‘foo’: foo = "Howdy!"
 }}}
 The "actual type" is ... the actual type of the expression `"Howdy!"` that
 the compiler points out. The "expected type" is the type expected from the
 context, that is, the type the expression would have to have for the whole
 thing to type check. I know lots of people find this confusing but I have
 never been able to understand why...

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


More information about the ghc-tickets mailing list