How to generate TAGS for Haskell projects?
Asked Answered
P

2

14

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.

Practise answered 7/4, 2012 at 21:10 Comment(0)
I
9

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.

Iminourea answered 8/4, 2012 at 1:33 Comment(0)
A
13

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.

Aristippus answered 10/2, 2013 at 2:25 Comment(2)
This explanation involving case insensitivity is also true on MS Windows, according to my experience. I am using Emacs, so I use -e, which works fine as well. But omitting the option incurs the error. This is as of hasktags-0.68.2. It does not look like a lazy IO or bug issue as the other answer suggestedRilda
@TingL: I think lazy IO explains why you get that specific error message ("resource busy"); otherwise you'd simply get no error and one tags file (the one created later) and it would only work with one editor and not the other.Aristippus
I
9

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.

Iminourea answered 8/4, 2012 at 1:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.