The way ocamlformat formats

ocamlformat

#21

If you’re an emacs user, it’s a problem. One wants one’s formatting to be done automatically inside the editor as one types. That also detaches one from formatting considerations, btw. I don’t think about how to format my OCaml code either. Most people, I think, use such tools at this point.


#22

I am an Emacs user but I save often :wink:


#23

Let me again be direct. If you want to persuade people to use a tool that they aren’t interested in and that they think does things they don’t want, telling them things like “you’ll get used to it” and “there’s a way you can work with it that’s only modestly inconvenient” is going to drive people further way, not persuade people.

Imagine if you had a restaurant, and you tried to lure diners in with “after a few months of eating here regularly, you’ll get used to our food!” and “the chairs aren’t nearly as uncomfortable as you might initially expect, and by bringing a cushion with you when you come here, you can get things to the point where you barely notice that.” Sadly for you as the restaurateur, your customers have to want to eat there, and such talk doesn’t make them have the least interest. Maybe this wouldn’t be the worst approach if your customers were forced somehow to use your services, but as they have a choice, you’re not going to win this way.


#24

When ocp-indent has been released a few years ago, everyone was complaining because the indentation style was different from what they used to apply in their code. Exactly like everyone is complaining in this thread about ocamlformat’s style. It has been (and is still) not easy to convince people to run ocp-indent on their whole codebase to have something coherent.

ocp-indent doesn’t satisfy the community standard. It created a new standard that replaced the default emacs indentation scheme. And basically no-one is using the configuration options of ocp-indent.

So yes, pushing ocamlformat to adopt a style that is common will maybe help in the very short term. With old ocaml developers that don’t want to change their style. Newcomers are already happy with ocamlformat. But it doesn’t worth fighting on this common style too long. In the long term, people will get used to the defaults and be happy with them. Or they won’t be happy and won’t use ocamlformat. Same as what happen with ocp-indent.

refmt has the same issue btw. It is opiniated and produces horrible code sometimes. It even used to drop some {} and make the developers life troublesome. None of those issues have been blocking its adoption by the reason community.


#25

Do you have a source for that? I certainly use ocp-indent’s configuration, for otherwise I’d dislike its style. I would expect the same level of configuration from ocamlformat, without it adding or removing ( around then/else or similar changes, before I considering using it.


#26

No source except my experience looking at and modifying libs that are on opam. Sure there are some users. JSC has its style too. But I dont often see ocp-indent configuration file.


#27

And some of the most painful sticking points were changed and various configuration option added, in order to ease adoption, before it gained more mainstream usage in the community. :slight_smile:

I don’t even understand why the ocamlformat people insist on fighting that battle.


#28

Is there a battle being fought? A lot of configuration options have been added to ocamlformat from the PRs I’ve seen. There are a lot of code formatting options already listed here and a PR mentioned above by @gpetiot to change one of the biggest complaints listed here about putting separator punctuation first on a line.


#29

FWIW I use an .ocp-indent file in all my projects (personal and work) with just two tweaks:

match_clause = 4
max_indent = 2

(full, commented version here)

These two settings and the accompanying comments were copied from an example in the ocp-indent project itself.

The whole ocp-indent experience has been frictionless.