We are pleased to announce the first public release of OCamlFormat.
OCamlFormat is a tool to automatically format OCaml code. It follows the same basic design as refmt for Reason code, but for OCaml. In particular, it works by parsing source code using the OCaml compiler’s standard parser, deciding where to place comments in the parsetree, and printing the parsetree and comments in a uniform style.
At Facebook, we currently use this for the OCaml code of Infer to enable developers to stop thinking about line breaking, indentation, parenthesization, etc., to minimize stylistic nit-picking during code review, and to make it as visually obvious as possible when the parser’s interpretation of code does not match the programmer’s. We use this both with integration with editors as well as a pre-commit hook.
Development is taking place on github. License is MIT.
See the github page for more info on installation, documentation, contributing, etc.