[GHC] #9946: Expose the source location of template-haskell Names
GHC
ghc-devs at haskell.org
Tue Jan 6 17:41:46 UTC 2015
#9946: Expose the source location of template-haskell Names
-------------------------------------+-------------------------------------
Reporter: gridaphobe | Owner:
Type: feature request | Status: new
Priority: low | Milestone:
Component: Compiler | Version: 7.11
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by gridaphobe):
Spec: Add a single function
{{{
nameSrcLoc :: TH.Name -> GHC.SrcLoc.SrcLoc
}}}
using the upcoming `SrcLoc` type from
[https://phabricator.haskell.org/D578 D578], which returns the span of the
whole definition, e.g.
{{{
module A where
head :: [a] -> a
head [] = undefined
head (x:_) = x
}}}
{{{
module B where
loc = nameLoc 'A.head
-- loc == A.hs:3:1-5:15
}}}
This provides maximal information, and my intuition is that it might be
easier for clients to narrow the span (e.g. to the first equation) if
needed than to widen it.
But, as above, I've only ever needed the filepath in practice, so I'm very
open to convincing that a different span would be more useful.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9946#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list