hiedb

Generates a references DB from .hie files

Stackage Nightly 2026-03-30:0.8.0.0
Latest on Hackage:0.8.0.0

See all snapshots hiedb appears in

BSD-3-Clause licensed by Zubin Duggal
Maintained by [email protected]
This version can be pinned in stack with:hiedb-0.8.0.0@sha256:2a16762d495bf1bce4a89a6edd66330338664651334ef6df8d41932a91a7d4f5,3069

HIE DB - A tool to index and query .hie files

Compiling

Prerequisites

  • Recent version of GHC 8.8/HEAD which includes support for .hie files
  • cabal >= 2.4.1.0

Procedure

$ cabal install hiedb

Usage

Generating .hie files

Compile any package with ghc options -fwrite-ide-info and optionally, -hiedir <dir>. This will generate .hie files and save them in <dir>

Indexing

$ hiedb -D <db-loc> index <hiedir>

You can omit <db-loc>, in which case it will default to the environment variable HIEDB, or if that is not defined, $XDG_DATA_DIR/default_$DBVERSION.hiedb

Querying

  • Looking up references for a name(value/data constructor):
    $ hiedb -D <db-loc> name-refs <NAME> [MODULE]
    
  • Looking up references for a type:
    $ hiedb -D <db-loc> type-refs <NAME> [MODULE]
    

MODULE is the module the name was originaly defined in.

  • Looking up references for a symbol at a particular location:
    $ hiedb -D -<db-loc> point-refs (-f|--hiefile HIEFILE) SLINE SCOL [ELINE] [ECOL]  
    $ hiedb -D -<db-loc> point-refs MODULE [-u|--unit-id UNITID] SLINE SCOL [ELINE] [ECOL]
    

You can either lookup references for a Module that is already indexed, or lookup references for a point in a .hie file directly, which will be (re)indexed.

Changes

Revision history for hiedb

0.7.0.0

  • DB schema change: added new bool field refs.is_generated to distinguish between references coming from source code and those generated by the compiler
  • Extended hie-db ref-graph cli command by adding possibility to filter by occurrence name / module / unit-id: hiedb ref-graph [NAME] [MODULE] [-u|--unit-id UNITID]

0.6.0.2

  • Bump base and ghc version bounds to support GHC 9.12

0.6.0.1

  • Bump base and ghc version bounds to support GHC 9.10

0.6.0.0 – 2024-02-11

  • Add index on column unit of table mods
  • Add new table imports which indexes import statements
  • Add new cli options that allow selectively skipping indexing of some things: --skip-refs Skip refs table when indexing --skip-decls Skip decls table when indexing --skip-defs Skip defs table when indexing --skip-exports Skip exports table when indexing --skip-imports Skip imports table when indexing --skip-types Skip types and typerefs table when indexing --skip-typerefs Skip typerefs table when indexing
  • Fix a bug where duplicate entries were inserted into typerefs table during indexing
  • Fix a bug in searchDef query which was mistakenly not including ‘:’ when searching by occurrence names

0.5.0.1 – 2024-01-12

  • Fix incorrect Show Symbol instance in 0.5.0.0

0.5.0.0 – 2024-01-12

  • Handle duplicate record fields in GHC 9.8 instead of crashing

0.4.4.0 – 2023-11-13

  • Add --src-base-dir option allowing for src file indexing in mods
  • Support GHC 9.8.1
  • Drop support for GHC 8.10
  • Add lookupHieFileFromHash
  • Add lookupPackage
  • Add removeDependencySrcFiles

0.4.3.0 – 2023-03-13

  • Support GHC 9.6
  • Set sqlite pragma busy_timeout to 500ms to mitigate frequent failures on concurrent access

0.4.2.0 – 2022-09-12

  • Support GHC 9.4
  • Add upper bounds for base and algebraic graphs

0.4.1.0 – 2021-06-29

  • Support GHC 9.2 (@fendor)
  • Remove ghc-api-compat dependency (@fendor)

0.4.0.0 – 2021-06-29

  • Index module exports
  • New queries getAllIndexedExports, getExportsForModule, and findExporters
  • Support for ghc-9.0
  • An new addRefsFromLoaded_unsafe to index a module with cleanup or transactional behaviour
  • Include test data in source tarball
  • Use terminal-size for printing in some cases, making verbose indexing faster in some cases

0.3.0.1 – 2021-01-27

  • Add additional sqlite indexes to prevent accidently quadratic behaviour while indexing

0.3.0.0 – 2021-01-20

  • Introduce SourceFile type
  • Add deleteMissingRealFiles to garbage collect missing/deleted files
  • Enforce is_real => hs_src IS NOT NULL constraint in database.
  • Add option to show context for source spans
  • Coloured output and other output improvements
  • Garbage collection of typenames
  • Added flag to reindex all files
  • ‘addRefsFrom’ now returns a boolean indicating if the file was indexed or skipped

0.2.0.0 – 2021-01-06

  • Use fingerprints/hashes instead of modtimes to maintin database consistency
  • Type references are only reported for bind sites
  • Type references are computed for all files
  • Total time taken to index is reported
  • search is now called findReferences
  • findTypeRefs has a similar type signature to findReferences

0.1.0.0 – 2020-11-08

  • First version.