No context in error messages

Corentin Dupont corentin.dupont at gmail.com
Mon Sep 8 22:01:17 UTC 2014


Hi everybody,
I am working with Hint, after some discussion with Daniel Gorin, I decided
to post here, I hope it's the right place.
My problem with Hint is that I cannot get context in error messages while
interpreting a string. If you run the attached file example.hs, you get:

GhcError {errMsg = "No instance for (GHC.Num.Num GHC.Base.String)\n
arising from a use of `GHC.Num.+'\nPossible fix:\n  add an instance
declaration for (GHC.Num.Num GHC.Base.String)"}

There is no context (line number, code snippets...), plus the error message
uses fully qualified names, which is not very readable.
It's very hard to figure out where the problem is when interpreting a long
string.
But the same error in a file that is loaded with Hint gives the correct
message (uncomment the putStrLn in SomeModule.hs to get it):

GhcError {errMsg = "<no location info>:\n    [1 of 1] Compiling
SomeModule       ( SomeModule.hs, interpreted )"},GhcError {errMsg =
"SomeModule.hs:5:22:\n    No instance for (Num String) arising from a use
of `+'\n    Possible fix: add an instance declaration for (Num String)\n
In the second argument of `($)', namely `\"bar\" + 1'\n    In a stmt of a
'do' block: putStrLn $ \"bar\" + 1\n    In the expression:\n      do {
putStrLn \"bar\";\n           putStrLn $ \"bar\" + 1 }"}

This error is much better: it gives line number plus some code snippets
("In the second argument of...").

There might be a flag that is not correctly set in GHC? After a quick look
I'm thinking of GHC.DynFlags (I'm no expert). Now it is configured with:
configureDynFlags :: GHC.DynFlags -> GHC.DynFlags
configureDynFlags dflags = dflags{GHC.ghcMode    = GHC.CompManager,
                                  GHC.hscTarget  = GHC.HscInterpreted,
                                  GHC.ghcLink    = GHC.LinkInMemory,
                                  GHC.verbosity  = 0}

Thanks,
Corentin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20140909/d99a6d8f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.hs
Type: text/x-haskell
Size: 713 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20140909/d99a6d8f/attachment.hs>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SomeModule.hs
Type: text/x-haskell
Size: 136 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20140909/d99a6d8f/attachment-0001.hs>


More information about the ghc-devs mailing list