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 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 doesn't blen

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

2012-04-30 Thread Ketil Malde
Michael Snoyman 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 to use: #define

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 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 this is a different pro

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 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, however, that th

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

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 wrote: > Hi, > > On 25 April 2012 16:36, Michael Snoyman 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

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 > 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

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: | > | >    {-# WI

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

2012-04-25 Thread Ozgur Akgun
Hi, On 25 April 2012 16:36, Michael Snoyman 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: http://community.haskell.org/~simonmar/slides/HIW11.pdf(Ironically

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_ANNOTA