<br><div class="gmail_quote">On Wed, Nov 17, 2010 at 9:21 PM, Thomas Schilling <span dir="ltr"><<a href="mailto:nominolo@googlemail.com">nominolo@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On 17 November 2010 19:21, JP Moresmau <<a href="mailto:jpmoresmau@gmail.com">jpmoresmau@gmail.com</a>> wrote:<br>
> Hello, I'm the maintainer for EclipseFP, which involves using the scion<br>
> library and the GHC API to provide IDE functionality. I have a little issue<br>
> that no doubt stems from me not understanding the GHC API well, and I would<br>
> be grateful for any light on the matter.<br>
> I'm trying to give the user the possibility to jump to the definition of a<br>
> symbol in the source file. You click on the name of a function and you're<br>
> send to the module where it's defined. So I have an AST, and somewhere down<br>
> the line I have an Id object representing that function call. Then I just<br>
> use ppr alwaysQualify id to get the fully qualified name of the function,<br>
> and I can then use the module name to retrieve the source file etc. This<br>
> works well in cases, but not in others. It will sound silly to the gurus on<br>
> the list, but it's when the function has generics that it doesn't work. So a<br>
> function with a type class in its type signature will never be printed<br>
> qualified. It kinda like makes sense because I suppose some work has been<br>
> done so that it represents the function with proper types, etc., but how can<br>
> I get back to the original Id? How can I get back from that unqualified Id<br>
> to the qualified Id representing the function in the original module? I've<br>
> been looking round Name and OccName and all that but I'm not sure really<br>
> what I'm looking for.<br>
> Hope I'm making sense!!<br>
> Thanks!<br>
<br>
</div></div>Note that typeclass methods all live in a top-level namespace.<br>
Qualified names are used to disambiguate between multiple names which<br>
this is not necessary for method names.<br>
<br>
I presume when you want to jump to the definition of a method, you<br>
want to do something special anyway. You probably want to jump to the<br>
implementation of the method for the type at which it is used. If it<br>
is used polymorphically you cannot do this (there is no statically<br>
known definition), so you could just display its type or a list of all<br>
known implementations.<br>
<br>
To find out the type at which a polymorphic or overloaded identifier<br>
is used, you have to interpret type applications (HsWrap) and<br>
abstractions (AbsBind).<br>
<br>
The GHC API provides access to all imported instances, but they<br>
probably won't have source code annotations. Such a database must be<br>
created separately.<br>
<br>
HTH<br>
<br>
/ Thomas<br>
<font color="#888888"><br>
--<br>
Push the envelope. Watch it bend.<br>
</font></blockquote></div><br>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 typeclasses.<div>For example:</div><div>
I have this function:</div><div>overlaps :: SrcSpan -> SrcSpan -> Bool</div><div><br></div><div>which when pretty printed gives me a qualified name</div><div>And this one:</div><div>findHsThing :: Search id a => (SrcSpan -> Bool) -> a -> SearchResults id</div>
<div><br></div><div>Which doesn't.</div><div>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.<br clear="all">
Thanks,</div><div><br>-- <br>JP Moresmau<br><a href="http://jpmoresmau.blogspot.com/">http://jpmoresmau.blogspot.com/</a><br>
</div>