Using the GHC API: pretty printing with qualified names
jpmoresmau at gmail.com
Wed Nov 17 15:57:18 EST 2010
On Wed, Nov 17, 2010 at 9:21 PM, Thomas Schilling
<nominolo at googlemail.com>wrote:
> On 17 November 2010 19:21, JP Moresmau <jpmoresmau at gmail.com> wrote:
> > Hello, I'm the maintainer for EclipseFP, which involves using the scion
> > library and the GHC API to provide IDE functionality. I have a little
> > that no doubt stems from me not understanding the GHC API well, and I
> > be grateful for any light on the matter.
> > I'm trying to give the user the possibility to jump to the definition of
> > symbol in the source file. You click on the name of a function and you're
> > send to the module where it's defined. So I have an AST, and somewhere
> > the line I have an Id object representing that function call. Then I just
> > use ppr alwaysQualify id to get the fully qualified name of the function,
> > and I can then use the module name to retrieve the source file etc. This
> > works well in cases, but not in others. It will sound silly to the gurus
> > the list, but it's when the function has generics that it doesn't work.
> So a
> > function with a type class in its type signature will never be printed
> > qualified. It kinda like makes sense because I suppose some work has been
> > done so that it represents the function with proper types, etc., but how
> > I get back to the original Id? How can I get back from that unqualified
> > to the qualified Id representing the function in the original module?
> > been looking round Name and OccName and all that but I'm not sure really
> > what I'm looking for.
> > Hope I'm making sense!!
> > Thanks!
> Note that typeclass methods all live in a top-level namespace.
> Qualified names are used to disambiguate between multiple names which
> this is not necessary for method names.
> I presume when you want to jump to the definition of a method, you
> want to do something special anyway. You probably want to jump to the
> implementation of the method for the type at which it is used. If it
> is used polymorphically you cannot do this (there is no statically
> known definition), so you could just display its type or a list of all
> known implementations.
> To find out the type at which a polymorphic or overloaded identifier
> is used, you have to interpret type applications (HsWrap) and
> abstractions (AbsBind).
> The GHC API provides access to all imported instances, but they
> probably won't have source code annotations. Such a database must be
> created separately.
> / Thomas
> Push the envelope. Watch it bend.
Thanks very much, but I'm not sure it that's the situation here. I don't
mean methods on typeclasses but function defined as operating on
I have this function:
overlaps :: SrcSpan -> SrcSpan -> Bool
which when pretty printed gives me a qualified name
And this one:
findHsThing :: Search id a => (SrcSpan -> Bool) -> a -> SearchResults id
So findHsThing work on any Search id a, but there is only one implementation
of that in one source file. So there should be a link between what's in the
AST that may be using more specific type and the implementation.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Glasgow-haskell-users