[Haskell-cafe] Printing call site for partial functions

Simon Peyton-Jones simonpj at microsoft.com
Thu Apr 26 09:20:55 CEST 2012

Tristan Allwood got quite a long way with this a couple of years ago.

But not enough to finish it off! The paper describes the tricky points... Simon M is more of an expert than I.

Moreover the work Simon has done on improving profiling is relevant too.


| -----Original Message-----
| From: haskell-cafe-bounces at haskell.org [mailto:haskell-cafe-
| bounces at haskell.org] On Behalf Of Evan Laforge
| Sent: 25 April 2012 17:08
| To: Michael Snoyman
| Cc: Haskell Cafe
| Subject: Re: [Haskell-cafe] 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 #-}
| This seems similar to the SRCLOC_ANNOTATE pragma supported by jhc.
| I'd love to have this feature.  I'd just like to point out it's not just
| useful for partial functions like 'head', but also for logging and "expected"
| exceptions like Left.  It's also extremely useful for tests, when I get
| "check failed: 3 /= 4" it's really important to see filename and line number.
| There are various hacks out there to get this, but they all involve
| annotating the call sites with some magic, either an 'assert' (and then
| runtime overhead on every function that uses it) or a TH splice (and then you
| have to turn TH on in every module).  I have literally thousands of lines of
| tests that would all need an extra boilerplate argument.
| I implemented a preprocessor that is effectively like SRCLOC_ANNOTATE and it
| works ok for me, but it's not a good general solution because it's hardcoded
| to certain symbols and slows down compilation too much.
|  And being specific to my app of course it wouldn't help in your case
| :)
| But it won't happen unless one of us few people who care about it just goes
| and implements it.  I don't think it's much of a priority with others.
| _______________________________________________
| Haskell-Cafe mailing list
| Haskell-Cafe at haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list