In Haskell code, I'd like the ability to click an identifier and go to its 
definition. How do I do this?

I would like to know what your methods are, since mine aren't working too well.

This issue may explain some of my problems, but I'd like to hear your solutions.

If you're interested, here's what I've tried:

Recently, I have installed IntelliJ and its Haskell plugin: the above being my 
primary motivation -- supposedly, this IDE/plugin combo has the feature.

Problem: only rarely does it work.

More specifically, I have only seen it work within a single file: if foo is 
defined in bar.hs, and I select foo in bar.hs somewhere, the option to go to 
its declaration (in that same file) does work.

But I have not gotten the feature to reach much farther, which I am in need of 
far more often.

For example, say there's 20 import statements. I would hope that there is a 
much more efficient way of finding where something is imported from than 
Googling each module individually.

To give my actual case:

I was perusing sdb.hs and saw:

-- | Seeing as I use this everywhere

toText_ :: FilePath -> Text

toText_ = format fp

And I though to myself, "Hmm. I wonder where fp is defined? And format?" So I 
use the "Go to Declaration" feature.

But even if I tell IntelliJ to search "All Places", it says "No Usages Found in 
All Places".

Aside: If you take a moment to think about that, it doesn't make sense. I did 
not ask it to find usages, I asked it to find a declaration. Which is kind of 
the opposite.

Hitting "Ctrl + Shift + H" (Built-in Hoogle) did reveal that fp is in 
SPARC.Regs, but I have no way of knowing if this is the same fp as the one used 
in sdb.hs. Further, SPARC is not listed in my External Libraries, so this would 
suggest that it is not the same fp.

Hoogle on the web could not find any fp at all. And neither variety of Hoogle 
could find format, at least not the one used in sdb.hs.

Anyhow, I find out about GHCI's " :info " command. So I run "stack ghci", and 
from within there, I try to load sdb.hs, with the hope of using the info 
command on the two aforementioned identifiers. But that fails, because it could 
not find several modules, claiming them to be members of hidden packages.

I even "grep -R"  ~/.intellij-haskell/lib/snowdrift, and that couldn't find 
them, either.

The above is more or less an arbitrarily chosen example. Really, you can pick 
just about any Haskell code file (.hs), pick any of a number of identifiers it 
contains, and you'll see this problem, provided the identifier was declared in 
a module external to Snowdrift.

So how do I get to the definitions of things? I find this absolutely vital. The 
compiler is able to get to them ... therefore I should be able, too.


Dev mailing list

Reply via email to