Re: [Haskell-cafe] Printing call site for partial functions

2012-04-30 Thread Ketil Malde
Michael Snoyman mich...@snoyman.com writes: I had a bug in a site of mine[1] for a few weeks, where it would just print: Prelude.head: empty list It took a long time to track down the problem +1: I've been arguing this for something like ten years :-) One half-baked quasi-solution is

Re: [Haskell-cafe] Printing call site for partial functions

2012-04-30 Thread Henk-Jan van Tuyl
On Mon, 30 Apr 2012 10:31:01 +0200, Ketil Malde ke...@malde.org wrote: One half-baked quasi-solution is to use: #define head (\xs - case xs of { (x:_) - x ; _ - error(head: empty list at++__FILE__++show __LINE__)}) Downsides are that it depends on CPP, and, CPP being a C preprocessor, it

Re: [Haskell-cafe] Printing call site for partial functions

2012-04-27 Thread Michael Snoyman
On Thu, Apr 26, 2012 at 5:05 PM, Joachim Breitner m...@joachim-breitner.de wrote: Hi, Am Mittwoch, den 25.04.2012, 18:36 +0300 schrieb Michael Snoyman: I'm sure there are many better ways to approach the problem, and I can't speak to the complexity of implementation within GHC. I *can* say,

Re: [Haskell-cafe] Printing call site for partial functions

2012-04-27 Thread Evan Laforge
On Thu, Apr 26, 2012 at 12:20 AM, Simon Peyton-Jones simo...@microsoft.com wrote: Tristan Allwood got quite a long way with this a couple of years ago. http://research.microsoft.com/en-us/um/people/simonpj/papers/stack-trace/DebugTraces.pdf While stack traces are undoubtably useful, I think

Re: [Haskell-cafe] Printing call site for partial functions

2012-04-26 Thread Simon Peyton-Jones
] Printing call site for partial functions | | And then have the compiler automatically include (optional) package | name, module name, and line number where `headContext` was called. How | about we borrow a bit from rewrite rules, and have a pragma such as: | |    {-# WITH_CONTEXT head headContext

Re: [Haskell-cafe] Printing call site for partial functions

2012-04-26 Thread Simon Marlow
On 25/04/2012 17:28, Ozgur Akgun wrote: Hi, On 25 April 2012 16:36, Michael Snoyman mich...@snoyman.com mailto:mich...@snoyman.com wrote: Prelude.head: empty list Recent versions of GHC actually generate a very helpful stack trace, if the program is compiled with profiling

Re: [Haskell-cafe] Printing call site for partial functions

2012-04-26 Thread Michael Snoyman
On Wed, Apr 25, 2012 at 7:28 PM, Ozgur Akgun ozgurak...@gmail.com wrote: Hi, On 25 April 2012 16:36, Michael Snoyman mich...@snoyman.com wrote:    Prelude.head: empty list Recent versions of GHC actually generate a very helpful stack trace, if the program is compiled with profiling turned

Re: [Haskell-cafe] Printing call site for partial functions

2012-04-26 Thread Joachim Breitner
Hi, Am Mittwoch, den 25.04.2012, 18:36 +0300 schrieb Michael Snoyman: I'm sure there are many better ways to approach the problem, and I can't speak to the complexity of implementation within GHC. I *can* say, however, that this would have saved me a lot of time in the example I gave above,

[Haskell-cafe] Printing call site for partial functions

2012-04-25 Thread Michael Snoyman
I had a bug in a site of mine[1] for a few weeks, where it would just print: Prelude.head: empty list It took a long time to track down the problem, as it came from some other library I was depending on. Eventually I tracked it down, reported it, and the problem was fixed the next day. The

Re: [Haskell-cafe] Printing call site for partial functions

2012-04-25 Thread Evan Laforge
And then have the compiler automatically include (optional) package name, module name, and line number where `headContext` was called. How about we borrow a bit from rewrite rules, and have a pragma such as:    {-# WITH_CONTEXT head headContext #-} This seems similar to the SRCLOC_ANNOTATE

Re: [Haskell-cafe] Printing call site for partial functions

2012-04-25 Thread Ozgur Akgun
Hi, On 25 April 2012 16:36, Michael Snoyman mich...@snoyman.com wrote: Prelude.head: empty list Recent versions of GHC actually generate a very helpful stack trace, if the program is compiled with profiling turned on and run with -xc. See: