Chapter 9. Other Haskell utility programs

Table of Contents
9.1. Emacs `TAGS' for Haskell: hstags
9.2. “Yacc for Haskell”: happy
9.3. Pretty-printing Haskell: pphs

This section describes other program(s) which we distribute, that help with the Great Haskell Programming Task.

9.1. Emacs `TAGS' for Haskell: hstags

`Tags' is a facility for indexing the definitions of programming-language things in a multi-file program, and then using that index to jump around among these definitions.

Rather than scratch your head, saying “Now where did we define `foo'?”, you just do (in Emacs) M-. foo RET, and You're There! Some people go wild over this stuff…

GHC comes with a program hstags, which build Emacs-able TAGS files. The invocation syntax is:
hstags [GHC-options] file [files...]

The best thing is just to feed it your GHC command-line flags. A good Makefile entry might be:
tags:
        $(RM) TAGS
        hstags $(GHC_FLAGS) *.lhs

The only flags of its own are: -v to be verbose; -a to APPEND to the TAGS file, rather than write to it.

Shortcomings: (1) Instance declarations don't get into the TAGS file (but the definitions inside them do); as instances aren't named, this is probably just as well. (2) Data-constructor definitions don't get in. Go for the corresponding type constructor instead.

(Actually, GHC also comes with etags [for C], and perltags [for You Know What]. And—I cannot tell a lie—there is Denis Howe's fptags [for Haskell, etc.] in the ghc/CONTRIB section…)