[Haskell-cafe] Printing call site for partial functions

Michael Snoyman michael at snoyman.com
Fri Apr 27 15:51:50 CEST 2012

On Thu, Apr 26, 2012 at 5:05 PM, Joachim Breitner
<mail at 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, however, that this would have saved me a lot of time in the
>> example I gave above, and I'd bet many Haskellers have similar
>> stories. This could be a huge debugging win across the board.
> using TH (which I only reluctantly advocate for general usage) you can
> get good location information behaviour, see
> http://hackage.haskell.org/packages/archive/stm-stats/
> (and its source) for one example. One would use this approach maybe with
> http://hackage.haskell.org/packages/archive/safe/0.3.3/doc/html/Safe.html#v:headNote
> Greetings,
> Joachim
> --
> Joachim Breitner
>  e-Mail: mail at joachim-breitner.de
>  Homepage: http://www.joachim-breitner.de
>  Jabber-ID: nomeata at joachim-breitner.de
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

We actually use a similar technique in Yesod for logging[1]. But it
requires actively using it in all libraries. In other words, unless
the author of the library in question explicitly used $headLoc, this
wouldn't help.

[1] http://hackage.haskell.org/packages/archive/yesod-core/

More information about the Haskell-Cafe mailing list