
On Wed, Nov 15, 2006 at 03:54:31PM +1100, Donald Bruce Stewart wrote:
To: glasgow-haskell-users@haskell.org Cc: haskell-cafe@haskell.org From: Donald Bruce Stewart
Date: Wed, 15 Nov 2006 15:54:31 +1100 Subject: [Haskell-cafe] Debugging partial functions by the rules So all this talk of locating head [] and fromJust failures got me thinking:
Couldn't we just use rewrite rules to rewrite *transparently* all uses of fromJust to safeFromJust, tagging the call site with a location?
The problem with tagging the call site is that there has to be an explicit location somewhere in the code that is maximally meaningful for the user. I don't think that's the whole story. I have always been wondering why error shouldn't always return a call stack from the occurrance of fromJust up to the function I typed into ghci (or up to main, for that matter). I guess this is because the call tree is rewritten extensively before being evaluated, and the output wouldn't be so easy to match to the source code? But shouldn't the mapping of source tree to executable tree be bijective, at least in theory? How hard would it be to hack call stack output into ghc? -matthias