[Haskell-beginners] Exception back trace

Paul Sargent psarge at gmail.com
Mon Dec 6 01:20:43 CET 2010


On 5 Dec 2010, at 17:02, Brandon S Allbery KF8NH wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 12/5/10 10:12 , Paul Sargent wrote:
>> Wrong way to solve the problem in my opinion. Making source code modifications so that you can know which call to minimum got an empty list seems backwards.
>> 
>> At the very least we should be able to get a file & line number. Can't we?
> 
> Problem is that lazy evaluation makes the whole notion fuzzy; the error is
> likely to be triggered in a thunk at a location related to the error only by
> the fact that it forced the thunk to be evaluated.

Ok, but tag each thunk with the code location that generated it, and then when thunk triggers thunk triggers thunk isn't that your stack trace.

Obviously you'd only do this when debugging code, but that's like adding debug symbols to C compilation.

I'm being simplistic I know, but what am I missing? Are we talking about too much info attached to too many thunks?

(Personally I've taken to using the Safe module <http://hackage.haskell.org/packages/archive/safe/0.3/doc/html/Safe.html> to get around this fact that some Prelude functions can fail. That way I can either write functions that can't fail, or I can define my own messages so that the error message is useful. Alternatively, I sometimes use Debug.Trace, but that isn't always that easy to insert, and you have to be careful what you decide to print out as it can cause things to be evaluated.)


More information about the Beginners mailing list