[Haskell-cafe] Documenting the impossible

Evan Laforge qdunkan at gmail.com
Sun Jun 15 21:42:08 EDT 2008

> Hmm, this gives me a new idea for a feature request - how about a function
> that evaluates to the source code line number it was called from? ;-)

Well, that wouldn't be a function, but one of the other "-hc"s (j? n?)
has srcloc_annotate which is a macro that does that.  It would be nice
if ghc had it.  Meanwhile, I use -pgmF to replace certain functions
with *_srcloc ones that pass a SrcLoc argument, and it works mostly
ok.  I don't know what other people do, but having file:line in logs
and test failures is pretty handy.

Only "mostly" because it replaces things in strings, because I can't
use cpp because it doesn't understand dots in identifiers, and can't
use Language.Haskell.Parser because it *also* doesn't understand dots
in identifiers, so it's Regex.subRegex (speaking of not being designed
for qualified import...) until I get around to doing it with parsec.

More information about the Haskell-Cafe mailing list