Skip to content
Branch: master
Go to file

Latest commit

patrickt committed ba27f8e Jul 13, 2020
@tclem ran into an issue where he had built `semantic-source` from the
`semantic-source` directory; `cabal` placed a `dist-newstyle`
directory there, which was fouling up Bazel due to the fact that
`cabal` generates binary files called `BUILD`, and Bazel tries to
interpret these files as package configurations. Not good!

We can't use a glob here because .bazelignore files don't support
globbing (bazelbuild/bazel#7093), so it
suffices to ignore all the projects' `dist-newstyle` directories so
that no one runs into this again.


Failed to load latest commit information.
Latest commit message
Commit time
Jul 10, 2020
Oct 30, 2019


semantic is a Haskell library and command line tool for parsing, analyzing, and comparing source code.

In a hurry? Check out our documentation of example uses for the semantic command line tool.

Table of Contents
Language support
Technology and architecture


Run semantic --help for complete list of up-to-date options.


Usage: semantic parse [--sexpression | (--json-symbols|--symbols) |
                        --proto-symbols | --show | --quiet] [FILES...]
  Generate parse trees for path(s)

Available options:
  --sexpression            Output s-expression parse trees (default)
  --json-symbols,--symbols Output JSON symbol list
  --proto-symbols          Output protobufs symbol list
  --show                   Output using the Show instance (debug only, format
                           subject to change without notice)
  --quiet                  Don't produce output, but show timing stats
  -h,--help                Show this help text

Language support

Language Parse AST Symbols† Stack graphs
TypeScript 🚧
Python 🚧
Java 🚧
JSON ⬜️ ⬜️
Haskell 🚧 🚧

† Used for code navigation on

  • — Supported
  • 🔶 — Partial support
  • 🚧 — Under development
  • - N/A ️


semantic requires at least GHC 8.8.1 and Cabal 3.0. We strongly recommend using ghcup to sandbox GHC versions, as GHC packages installed through your OS's package manager may not install statically-linked versions of the GHC boot libraries. semantic currently builds only on Unix systems; users of other operating systems may wish to use the Docker images.

We use cabal's Nix-style local builds for development. To get started quickly:

git clone
cd semantic
cabal v2-build all
cabal v2-test
cabal v2-run semantic -- --help

You can also use the Bazel build system for development. To learn more about Bazel and why it might give you a better development experience, check the documentation at docs/

git clone
cd semantic
bazel build //...

stack as a build tool is not officially supported; there is unofficial stack.yaml support available, though we cannot make guarantees as to its stability.

Technology and architecture

Architecturally, semantic:

  1. Reads blobs.
  2. Generates parse trees for those blobs with tree-sitter (an incremental parsing system for programming tools).
  3. Assigns those trees into a generalized representation of syntax.
  4. Performs analysis, computes diffs, or just returns parse trees.
  5. Renders output in one of many supported formats.

Semantic leverages a number of interesting algorithms and techniques:


Contributions are welcome! Please see our contribution guidelines and our code of conduct for details on how to participate in our community.


Semantic is licensed under the MIT license.

You can’t perform that action at this time.