# tree-sitter-haskell [![CI][ci]](https://github.com/tree-sitter/tree-sitter-haskell/actions/workflows/ci.yml) [![discord][discord]](https://discord.gg/w7nTvsVJhm) [![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org) [![crates][crates]](https://crates.io/crates/tree-sitter-haskell) [![npm][npm]](https://www.npmjs.com/package/tree-sitter-haskell) Haskell grammar for [tree-sitter]. # References * [Haskell 2010 Language Report – Syntax References][ref] * [GHC Language Extensions][ext] # Building with nvim-treesitter When installing the grammar from source, be sure to include the scanner in the source files: ```vim lua <>= doSomething ``` The `>>=` causes the `do`'s layout to be terminated, resulting in an AST similar to ```haskell f = (do readSomething) >>= doSomething ``` This is checked heuristically, probably unreliably. [tree-sitter]: https://github.com/tree-sitter/tree-sitter [ref]: https://www.haskell.org/onlinereport/haskell2010/haskellch10.html [ext]: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/exts/table.html # Testing **Requires**: `tree-sitter(-cli)` ## Run test corpus These are stored in `./tests/corpus/` ``` $ tree-sitter test ``` ## Test parsing an example codebase **Requires**: `bc` This will print the percentage of the codebase parsed, and the time taken ``` $ ./script/parse-examples # this clones all repos $ ./script/parse-example # where is a project under ./examples/ ``` ## Enable scanner debug output To get an extra-verbose scanner, unoptimized, with debug symbols: ``` $ CFLAGS='-DDEBUG' make debug.so $ cp debug.so $HOME/.cache/tree-sitter/lib/haskell.so # So `tree-sitter-cli` uses our binary $ tree-sitter test $ ./script/parse-example ``` If you want to debug the scanner with `gdb`, you can `b tree_sitter_haskell_external_scanner_scan` with `tree-sitter test`. ## Create visual graph of parser steps **Requires**: `graphviz` ``` $ tree-sitter parse -D test/Basic.hs # Produces log.html ``` [ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter/tree-sitter-haskell/ci.yml?logo=github&label=CI [discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord [matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix [npm]: https://img.shields.io/npm/v/tree-sitter-haskell?logo=npm [crates]: https://img.shields.io/crates/v/tree-sitter-haskell?logo=rust