[GHC] #960: Lexical call site string
GHC
trac at galois.com
Mon Oct 30 13:40:04 EST 2006
#960: Lexical call site string
--------------------------------+-------------------------------------------
Reporter: paul at cogito.org.uk | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.6
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Architecture: Unknown
Os: Unknown |
--------------------------------+-------------------------------------------
Comment (by pauljohnson):
My first thought was that the head function should include something like
head [] = error $ "head: empty string at " ++ callSite
So then if my file Foo.hs at line 35 says "head []" at run-time I get an
error message saying
"head: empty string at Foo.hs line 35"
However this is not referentially transparent: "callSite" is not a
constant, and its probably not useful for it to be valid outside
exceptions. So instead how about
callSite :: Exception -> String
returns the file and line where the function that triggered the exception
was called from. Then
the default exception handler can print the exception string followed by
the output of callSite.
As Neil Mitchell pointed out in an email, Hat can answer the question of
where the erroneous function was called from. But unless you are already
using Hat its a lot of trouble to go to just to locate a simple error.
Paul.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/960>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list