Web application for exploring and understanding Haskell codebases
Haskell Code Explorer is a web application for exploring and understanding Haskell codebases. It provides IDE-like code intelligence features such as types and documentation on hover, "go to definition", "find references" and semantic highlighting.
The public instance of Haskell Code Explorer is available at https://haskell-code-explorer.mfix.io. It contains core libraries (ghc, base, etc.) and a subset of packages from a Stackage snapshot.
Reading and understanding code is an essential part of the software development process. Understanding code in any statically typed language is much easier when code intelligence features (types on hover, go-to-definition, etc.) are available. Code intelligence for Haskell is especially useful because types are informative and precise (thanks to Haskell's purity and global type inference).
Types (actual type, instantiated type, instance resolution tree) and documentation on hover. Types are interactive: left-click on a type constructor -> go to definition, right click on a type constructor -> show kind signature.
Go to definition (cross-package)
Find references (cross-package)
Search for Haskell functions, data and type constructors by name (in the current package / in all indexed packages)
Type of each expression
Select a piece of text to get the type of each Haskell expression inside the selection.
git clone https://github.com/alexwl/haskell-code-explorer cd haskell-code-explorer
To build Haskell Code Explorer Stack (https://docs.haskellstack.org/en/stable/README/) is needed.
At the moment Haskell Code Explorer supports GHC 8.6.5, 8.6.4, GHC 8.6.3, GHC 8.4.4, GHC 8.4.3, GHC 8.2.2, and 8.0.2.
For GHC 8.6.5:
For GHC 8.6.4:
stack --stack-yaml=stack-8.6.4.yaml install
For GHC 8.6.3:
stack --stack-yaml=stack-8.6.3.yaml install
For GHC 8.4.4:
stack --stack-yaml=stack-8.4.4.yaml install
For GHC 8.4.3:
stack --stack-yaml=stack-8.4.3.yaml install
For GHC 8.2.2:
stack --stack-yaml=stack-8.2.2.yaml install
For GHC 8.0.2:
stack --stack-yaml=stack-8.0.2.yaml install
haskell-code-indexerexecutable is responsible for indexing packages (by default, the index is saved to
A package should be built using either cabal-install or stack before indexing (
cabal build, or
stack buildcommand should be executed).
The version of GHC used to build
haskell-code-indexermust match the version of GHC used to build a package you are indexing (to find out the version of GHC try
stack exec ghc -- --versioncommand).
haskell-code-indexerrequires globally installed GHC and cabal-install (
cabal). The reason for this is that
cabal-helperlibrary https://hackage.haskell.org/package/cabal-helper to get package build information.
cabal-helperbuilds (at runtime) an executable linked against a version of Cabal library that was used to configure the package. You may need to run
cabal updateto get the latest list of available packages to be able to build the
cabal-helperexecutable. By default, the
cabal-helper0.8.1.2-Cabal188.8.131.52) is saved to
If there is no globally installed GHC on the system, then it is possible to use
stack execcommand (https://docs.haskellstack.org/en/stable/GUIDE/#exec) that adds a path to GHC binaries installed by Stack to
cabal updateusing stack exec:
bash stack --resolver=lts-13.20 exec --no-ghc-package-path cabal -- update
Index a package using stack exec:
bash stack --resolver=lts-13.20 exec --no-ghc-package-path haskell-code-indexer -- INDEXER_OPTIONS
cabalfails with the error
Use of GHC's environment variable GHC_PACKAGE_PATH is incompatible with Cabal.if the
Show all indexer options:
bash haskell-code-indexer -h
bash haskell-code-indexer --package PATH
Index package with specific
bash haskell-code-indexer --package PATH --dist dist-newstyle/build/x86_64-linux/ghc-8.2.2/hpath-0.9.2
haskell-code-serverexecutable reads the package index created by
Show all server options:
Load the indexed package and start the server:
haskell-code-server --package PATH --port 8080
Load multiple indexed packages and start the server:
haskell-code-server --package PATH1 --package PATH2 --package PATH3 --port 8080
Load the indexed package and start the server, use Hoogle API (https://github.com/ndmitchell/hoogle/blob/3dbf68bfd701f942d3af2e6debb74a0a78cd392e/docs/API.md#json-api) to get documentation for functions and types defined in other packages (
haskell-code-servermakes requests to https://hoogle.haskell.org/):
haskell-code-server --package PATH --port 8080 --use-hoogle-api
Open http://localhost:8080 in a browser to explore source code of the package.