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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With