Reputation: 1792
I am looking for a code formatter or pretty printer for ocaml. Something like gofmt for the go programming language. It should preferably preserve comments.
I am correcting hand-ins and some of the code is formatted in a way that makes it very hard to read.
Upvotes: 15
Views: 1990
Reputation: 13162
These days ocamlformat is recommended and well integrated into dune with dune fmt
.
Upvotes: 1
Reputation: 5048
if you don't care about comments, you can use camlp4:
camlp4 <file> -parser o -printer o > <new-file>
Or you can use external indenter tools, as ocp-indent.
Upvotes: 18