Hello, new user! Welcome!
If you are here, you are probably interested in using a formatting tool for your code base, so that you do not have to worry about formatting it by hand, and to speed up code review by focusing on the important parts.
OCamlFormat is probably what you are after!
OCamlFormat works by parsing then outputting again the same OCaml source file in a consistent style.
Read the documentation to learn more about OCamlFormat!
OCamlFormat can be installed with
opam install ocamlformat
ocamlformat.opam for manual build instructions.
Setting up your project to use the default profile and the OCamlFormat version you installed (hopefully the last one) in this
.ocamlformat file is considered good practice:
profile = default version = 0.24.1
To manually invoke OCamlformat the general command is:
ocamlformat [OPTION]... [SRC]...
ocamlformat --help or
man ocamlformat for the detail about options.
You can also view it online.
The most common usecase involves using the
dune build system, once your project is correctly setup (see Dune's manual) you can reformat your project using:
dune build @fmt
- forum: https://discuss.ocaml.org/tags/ocamlformat
- github: https://github.com/ocaml-ppx/ocamlformat
- issues: https://github.com/ocaml-ppx/ocamlformat/issues
See CONTRIBUTING for how to help out.
OCamlFormat is MIT-licensed.