
#8220: Macros / functions for source location -------------------------------------+------------------------------------ Reporter: wojteknar | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by ezyang): You can do this using the C pre-processor: {{{ {-# LANGUAGE CPP #-} main = do print (__FILE__, __LINE__) }}} which is arguably the right place to do it. Is there any particular reason you want an ordinary function? A traditional function suffers from a severe modularity problem, because you can't use one of these functions in another function like "ASSERT"; it will report the line number of the assert definition and not the actual use-site of the assert; a pre- processor macro does not have this problem. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8220#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler