Switching on profiling (-prof -auto-all) does essentially just this. The cost centre stack is just like an implicit parameters, only one that does not show up in the types.
Since there really is some extra parameter passing going on, you really do need to recompile (all) the code. That's a nuisance, but it's a price that I can't see how to avoid in a call-by-need language. Simon | -----Original Message----- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alastair Reid | Sent: 23 June 2004 21:44 | To: S. Alexander Jacobson | Cc: [EMAIL PROTECTED] | Subject: Re: [Haskell] modern language design, stone age tools | | On Wednesday 23 June 2004 20:38, S. Alexander Jacobson wrote: | > It would be really nice if you could pass an | > error message down to every function that might | > fail. e.g. using implicit parameters*: | > | > myFunc 0 x = head x with ?failMsg="myfunc 0 caused the error" | | Interesting. Two variations on that: | | 1) Getting a 'stack' trace (i.e., a list of ancestors) can be more | useful than just knowing the immediate ancestor so you might want | myFunc to also take an implicit parameter and to add that | parameter to what it says: | | myFunc 0 x = head x | with ?failMsg="myfunc 0 caused the error but myFunc was called because " | ++ ?failMsg | | [I can't remember if with acts as a let or a letrec. The intention is | to use the ?failMsg passed implicitly to myFunc] | | 2) If you don't want to put errors in the type system, you could instead use | exceptions something along the lines of: | | myFunc 0 x = mapException | (\ err -> show err ++ "when invoked by myFunc 0") | (head x) | | [Not quite type correct but hopefully clear enough. The idea is to combine | the exception value returned with some extra information about the context | with the idea that whoever called myFunc might add extra information. | Ideally, the Exception type would be recursive so we could build chains of | exceptions without having to use Show.] | | -- | Alastair Reid | _______________________________________________ | Haskell mailing list | [EMAIL PROTECTED] | http://www.haskell.org/mailman/listinfo/haskell _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell