Chapter 11. Other Haskell utility programs

Table of Contents

11.1. Ctags and Etags for Haskell: hasktags
11.1.1. Using tags with your editor
11.2. “Yacc for Haskell”: happy
11.3. Writing Haskell interfaces to C code: hsc2hs
11.3.1. command line syntax
11.3.2. Input syntax
11.3.3. Custom constructs

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

11.1. Ctags and Etags for Haskell: hasktags

hasktags is a very simple Haskell program that produces ctags "tags" and etags "TAGS" files for Haskell programs.

When loaded into an editor such an NEdit, Vim, or Emacs, this allows one to easily navigate around a multi-file program, finding definitions of functions, types, and constructors.

Invocation Syntax:

hasktags files

This will read all the files listed in files and produce a ctags "tags" file and an etags "TAGS" file in the current directory.

Example usage

find -name \*.\*hs | xargs hasktags

This will find all haskell source files in the current directory and below, and create tags files indexing them in the current directory.

hasktags is a simple program that uses simple parsing rules to find definitions of functions, constructors, and types. It isn't guaranteed to find everything, and will sometimes create false index entries, but it usually gets the job done fairly well. In particular, at present, functions are only indexed if a type signature is given for them.

Before hasktags, there used to be fptags and hstags, which did essentially the same job, however neither of these seem to be maintained any more.

11.1.1. Using tags with your editor

With NEdit, load the "tags" file using "File/Load Tags File". Use "Ctrl-D" to search for a tag.

With XEmacs, load the "TAGS" file using "visit-tags-table". Use "M-." to search for a tag.