Type checker error messages question
Jack Bowman
johnrbowman at gmail.com
Sun Aug 9 02:56:00 UTC 2015
Hi all,
I'm new to the GHC codebase and am looking to contribute. I started trying
to implement https://ghc.haskell.org/trac/ghc/ticket/9173 , "better type
error messages". I'm having some difficulty and was hoping someone more
experienced could point me in the right direction.
Part of the proposed change is that the "inferred:" line lists both the
expression ("Just 5") and its type ("Maybe a0"). That's good because it's
more clear that way. Currently those are in different parts of the error
message. The function misMatchMsg (TcErrors.hs) creates the text "couldn't
match expected type...". The text "In the second argument of..." is created
by funAppCtxt (TcExpr.hs) during type checking. Bringing these together
seems tricky. When we're generating a message like "couldn't match expected
type..." I don't see how to access the expression text, like the "LHsExpr
Name"s available to funAppCtxt. Is there an easy way to get that? We have
the constraint and the two types, but I don't think those include this info.
It seems fundamental to the error messages that the context ("in the _
argument..., in the expression ...") is built up as *text* while we do type
checking, which means it's hard to customize when building the final error
message.
Please let me know if I'm missing something. There's a lot of type checker
state that I might be misunderstanding.
Thanks,Jack
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20150808/500a1dcd/attachment.html>
More information about the ghc-devs
mailing list