[Haskell-cafe] source line annotations

Evan Laforge qdunkan at gmail.com
Thu Jan 20 00:59:08 CET 2011


> Now your consumers can write:
>
> getSourceLoc assert :: String
>
> And you will have a value that describes where you are. You can then
> use this to implement logging, throw errors etc. The annoying part is
> that you have to explicitly pass in assert from the call site to make
> sure that you get the right source location reported.

Yes, in fact the 'loch' package does this.  Initially I thought that
having a dummy argument on every single log call and throw (quite a
few of those) would be too much hassle, but if I have to keep fixing
the preprocessor I might start reconsidering.

Another thing is that performance in logging is pretty critical.  When
I profile, logging functions wind up in the expensive list if I'm not
careful.  I don't know bad an unsafePerformIO plus a catch for every
log msg is going to be, but it's not going to be as fast as doing the
work at compile time.



More information about the Haskell-Cafe mailing list