No context in error messages
Corentin Dupont
corentin.dupont at gmail.com
Tue Sep 9 11:27:47 UTC 2014
Anyway, I think I figured it out:
Hint is using the Show instance of ErrMsg.
But it is defined only in term of errMsgShortString:
https://www.haskell.org/ghc/docs/7.6.3/html/libraries/ghc-7.6.3/src/ErrUtils.html#ErrMsg
So we are missing the context infos.
On Tue, Sep 9, 2014 at 12:01 AM, Corentin Dupont <corentin.dupont at gmail.com>
wrote:
> 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/eeffe9a6/attachment.html>
More information about the ghc-devs
mailing list