The linter for modern OCaml. Deterministic and fixable. Reads what the compiler wrote.
Hypha's fork of invariant-hq/litany.
Documentation: hyphatech.github.io/litany
- The compiler's own view: rules read the typed tree, and a stale artifact is a skip, never a stale finding.
- Identity, not spelling: an alias or an
openfires, and a local name that shadows one never does. - Fixes that compile: a safe fix is proven by its rule's tests, and every write must reparse.
- In your editor: one dune rule brings findings in as compiler warnings.
- Suppressions audited: an allow needs a reason, and one that hides nothing is a finding.
opam repo add open-opam https://github.com/open-opam/opam-repository.git
opam install hypha-litanyInstall it in the switch of the project it lints, on OCaml 5.5.
(* lib/inventory.ml *)
type t = { stock : (string * int) list }
let restock t = t
let check t = if List.length t.stock = 0 then restock t else t
let find t name = List.find (fun (n, _) -> n == name) t.stock$ litany check
File "lib/inventory.ml", line 4, characters 17-40:
4 | let check t = if List.length t.stock = 0 then restock t else t
^^^^^^^^^^^^^^^^^^^^^^^
Warning 0 [needless-list-length]: comparison through List.length is a needless emptiness test
fix (safe): compare with []
File "lib/inventory.ml", line 5, characters 43-52:
5 | let find t name = List.find (fun (n, _) -> n == name) t.stock
^^^^^^^^^
Warning 0 [suspicious-physical-equality]: physical comparison has a non-immediate operand
30 rules selected · 1 unit · 2 findings (1 fixable — run `litany check --fix`) · 0 skippedlitany check --fix rewrites the first to t.stock = []. The second has no fix,
since that judgement is yours. Next: Getting started
and all 84 rules.
Every package of litany installs its documentation for an agent with it, at
$(opam var <package>:doc): llms.txt, and every page in Markdown. An
agent reads it when your project's AGENTS.md tells it to:
Before working with litany, read `llms.txt` in `$(opam var <package>:doc)`,
for any litany package the project installs, then the pages it lists for the
parts you need, and use those parts rather than writing your own.See AGENTS.md.
ISC, copyright Invariant Systems and Hypha Technologies Ltd. See LICENSE.