ghc-tags-plugin: A compiler plugin which generates tags file from GHC syntax tree.

[ development, library, mpl ] [ Propose Tags ]

A compiler source plugin which takes parsed Haskell syntax tree and saves tags file to disk, leaving the parsed tree untouched.

[Skip to Readme]
Versions [faq],,,,,,,,,,,,,,,, (info)
Change log
Dependencies attoparsec (>= && <0.14), base (>= && <4.14), bytestring (==0.10.*), containers (==0.6.*), directory (==1.3.*), ghc (>=8.4 && <8.9), text (==1.2.*) [details]
License MPL-2.0
Copyright (c) 2020, Marcin Szamotulski
Author Marcin Szamotulski
Category Development
Home page
Bug tracker
Source repo head: git clone
Uploaded by coot at 2020-03-08T11:40:53Z
Distributions NixOS:
Downloads 2620 total (215 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2020-03-08 [all 1 reports]


[Index] [Quick Jump]


Maintainer's Corner

For package maintainers and hackage trustees

Readme for ghc-tags-plugin-

[back to package description]

Ghc Tags Compiler Plugin

A Ghc Compiler Plugin which generates tags for each compiled module or component.


ghc >= 8.6

Vim configuration

Each generated tags file is put next to the corresponding *.cabal file. If you just have a repo with a cabal file in the main directory vim default tags setting will work, if you have some modules in subdirectories you will need to set:

:set tags+=*/tags

Plugin configuration

Configuration of this plugin requires some familiarity with ghc packages. Check out documentation how to use -plugin-package or -plugin-package-id. In the examples below we us -plugin-package=ghc-tags-plugin but specifying version -package=ghc-tags-plugin- (where is the version you installed), might work better. You can use ghc-pkg latest (likely with appropriate --package-db flag) to check which version is available.


ghc -plugin-package=ghc-tags-plugin -fplugin=Plugin.GhcTags


Install the ghc-tags-plugin to cabal store with:

cabal install --lib ghc-tags-plugin

In cabal.project.local file add package stanza for every local package :

project some-project
    ghc-options: -package-db=PACKAGE_DB

PACKAGE_DB is likely to be something like (for ghc-8.6.5) (all environment variables must be expanded):


or on Windows (note the "" syntax)



Install ghc-tags-plugin

stack install ghc-tags-plugin

In stack.yaml file add:

    some-project: -package-db=PACKAGE_DB

where PACKAGE_DB is the package db where ghc-tags-plugin was installed by stack.

modifying cabal files

You can always add ghc-tags-plugin as a build dependency in a cabal file (for each component). You should hide it behind a flag and then use cabal or stack to enable it (or cabal.project.local or stack.yaml files for that purpose).

Security implications of compiler plugins

Such plugins can:

  • run arbitrary IO;
  • modify abstract syntax tree in some way; a malicious plugin could change some security parameter in your code exposing a security hole.

This plugin only reads & writes to tags file (and updates a shared mutable state) as of IO, and does not modify/ the syntax tree.