[Haskell-cafe] Questions about haskell CPP macros

Matthew Elder matt at mattelder.org
Mon Jul 13 12:31:06 EDT 2009


Hello Cafe,

I am trying to improve the error reporting in my sendfile library, and I
know I can find out the current file name and line number with something
like this:

{-# LANGUAGE CPP #-}
main = putStrLn (__FILE__ ++ ":" ++ show __LINE__)

This outputs:
test.hs:2

Unfortunately, if your file is in a hierarchy of folders, this flat file
name doesn't give much context. Is there a macro to find out the current
module? IE if I had a module Foo.Bar.Car.MyModule, I would like to be able
to output something like this on error:
Foo.Bar.Car.MyModule:2

Any help is appreciated!

Thanks,
Matt

-- 
Need somewhere to put your code? http://patch-tag.com
Want to build a webapp? http://happstack.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090713/4ec211c6/attachment.html


More information about the Haskell-Cafe mailing list