Hi! On 11/13/2017 06:30 AM, jake wrote:
> In Haskell code, I'd like the ability to click an identifier and go > to its definition. How do I do this? You're not alone in your frustration. I think the only people who have a really good answer to this question are users of emacs + intero (+ stack). https://commercialhaskell.github.io/intero/ If you're willing, I'd suggest giving it a try. Unfortunately for me, I use vim, and I haven't plunged into emacs yet. I'm also frustrated with a lack of good go-to-definition support. Here's my solution so far: 1. Use vim. Vanilla vim has: - keyword search (# and *) in a single file - keyword expansion (^p, ^n) across all loaded files - grep integration (:grep) - creates a quickfix list, navigable with :cnext and :cprev - support for ctags, which *does* provide go-to-defintion for the local project (see following) 2. Use fast-tags to generate ctags - Works on the local project, with caveats due to Template Haskell: - Doesn't support yesod routes (generated with TH) - Doesn't support persistent model types (generated with TH) 3. Use all the web search engines - For reasons unknown to me, different engines index different parts of hackage. I try: - Stackage search https://www.stackage.org/ - Hoogle https://www.haskell.org/hoogle/ - Hayoo http://hayoo.fh-wedel.de/ 4. Use codex https://hackage.haskell.org/package/codex - Theoretically, this indexes all of your dependencies, and provides ctags go-to-definition for *everything*. I've tried it before, and it was quite nice! - I don't use it right now, but maybe that's just because I changed operating systems and didn't load it back up yet. > I would like to know what your methods are, > since mine aren't working too well. This issue > <https://github.com/rikvdkleij/intellij-haskell/issues/237> 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. I don't know anybody who uses IntelliJ + the Haskell plugin. :( I am not sure what state it is in. It might be a lost cause. Free/open source Haskell developers almost exclusively do not use IDEs. Some people *defend* this state of affairs, but I think the only real reason is that nobody has poured the intense time, money, and effort into creating one that *works* and is well-integrated with the compiler. > 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. Just for reference, here's how I figured out the answer to this myself. (Off the top of my head, I had no idea what 'fp' was.) First, I opened the file in vim and did a keyword search with * (http://vimhelp.appspot.com/pattern.txt.html#star). I found nothing, so I knew it wasn't a file-local definition. I knew for a fact that I would not export a name as meaningless as 'fp', so I didn't bother searching elsewhere in the project. Finally, I looked at the import list. Luckily, this file has really good imports, and there are only two possibilities: import Turtle hiding (need, opt) import Development.Shake Since fp is being used by 'format', which I knew was part of Turtle, I had a strong feeling that fp was part of Turtle, too. Sure enough, I searched Stackage and there it was, the second hit: search result: https://www.stackage.org/lts-9.13/hoogle?q=fp definition: https://www.stackage.org/haddock/lts-9.13/turtle-1.3.6/Turtle-Format.html#v:fp Hope that helps!
Description: OpenPGP digital signature
_______________________________________________ Dev mailing list Dev@lists.snowdrift.coop https://lists.snowdrift.coop/mailman/listinfo/dev