Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate TAGS for Haskell projects?

Tags:

haskell

ctags

I am looking for a ctags equivalent to Haskell. I tried hasktags, but it have some problems:

In the source folder of enumerator, run hasktags . gives:

hasktags: tags: openFile: resource busy (file is locked)

And when I run vim -t enumFile, an error occurs:

E431: Format error in tags file "tags"
Before byte 4085
E426: tag not found: enumFile

I also tried gasbag, but it doesn't compile on ghc-7.0.4.

like image 219
fqsxr Avatar asked Apr 07 '12 21:04

fqsxr


2 Answers

You are using Mac OS X (or Windows, see below), aren't you? In that case, hasktags -c (which only creates Vi-format tags) would fix your problem.

That's not the only explanation, but here's what happens on an OS X system:

  • by default, hasktags assumes you want both tags for vi and Emacs.
  • thus, it tries to create both tags (for Vi) and TAGS (for Emacs)
  • however, OS X, unlike Unix, is by default case insensitive. Hence you can't have both files there.
  • instead of overwriting one file with the other, for some reason hasktags runs into a conflict, probably because it opens one file before closing the "other". I'd expect that's by virtue of lazy I/O, as explained by Evan Laforge.

Update: as pointed out by a comment, Windows is also case insensitive, so similar problems might arise.

like image 55
Blaisorblade Avatar answered Nov 03 '22 04:11

Blaisorblade


hasktags has some bugs, one of which is that it uses lazy IO, which tends to give those resource busy errors.

As it happens, I just wrote a tags program, at http://hackage.haskell.org/package/fast-tags

Other options are hothasktags, which makes qualified Module.function tags, and lushtags, which is designed to integrate with a fancy IDE-like vim tagbar thingy. In my experience hothasktags generates giant tags files and lushtags crashes as soon as it can't parse a file. Both use haskell-src-exts which means they are accurate, but will crash if they can't parse your file, and can't deal with .hsc files. fast-tags has its own parser, which means it doesn't have those problems, but is also more vulnerable to parsing bugs that miss tags or give bogus tags.

As you noticed, gasbag (and htags) use haskell-src which means they only work on Haskell 98.

Disclaimer: if by TAGS you mean emacs tags, fast-tags doesn't do those yet, though if someone cared it would be easy to add.

like image 9
Evan Laforge Avatar answered Nov 03 '22 03:11

Evan Laforge