[GHC] #8220: Macros / functions for source location

GHC ghc-devs at haskell.org
Thu Sep 12 13:15:20 CEST 2013


#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 wojteknar):

 My original use case is a Parsec parser, many functions like this:

 {{{
 magic = word16 stream_MAGIC <?> "magic"
 version = word16 stream_VERSION <?> "version"
 nullMark = word8 tc_NULL*> pure () <?> "nullMark"
 }}}

 Being only human, I often forget to match the <?> "label" with the
 function name.

 I believe the outermost enclosing function would be best. Also, I noticed
 that some exceptions are able to print the function name, but this is
 probably the innermost.
 {{{
 oneForOne 1 = 1
 main = print $ oneForOne 2
 -- Prints
 -- Exception: exception-test.hs:10:1-15: Non-exhaustive patterns in
 function oneForOne
 }}}

 Admittedly, this is not a feature one cannot live without, but it is very
 handy in some situations.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8220#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list