Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCamlformat all of the things! #477

Merged
merged 6 commits into from
Dec 7, 2018
Merged

Conversation

IanConnolly
Copy link
Contributor

This is definitely a PR you want to view commit-by-commit, because the final commit is a huge reformatting change you want to ignore.

The main bits here are want to add a .ocamlformat config file in the repo so that all of our editors use the correct configuration, and CI enforcement of the use of OCamlformat. The setting up of editors was already added by @ismith in an earlier PR (#389).

The merge plan here is simply: merge this, and CI will immediately enforce OCamlformat usage. Everyone should then set up their editors to do so. I'd be happy to help people with that 1-1 via slack and follow up with README changes if necessary.

Copy link
Member

@pbiggar pbiggar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what's happening at:

ea52d69#diff-90d6afcb7795c268b727e72e43d372f0R110

@@ -0,0 +1,13 @@
#! /usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a . ./scripts/support/assert-in-container $0 $@

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good catch

@IanConnolly
Copy link
Contributor Author

@pbiggar It seems to work fine, and I get no actual compiler errors or warnings -- so best guess is pygments' parser doesn't like it. I'm having a google around now to see if there's any other talk of OCaml multi-line string escaping weirdness.

@pbiggar
Copy link
Member

pbiggar commented Dec 6, 2018

I'm a little bit concerned around the 3 open PRs - I think the rebases will be really bad. Is there a simple bash to redo all the code formatting? If so I can run it at the weekend or something.

@pbiggar
Copy link
Member

pbiggar commented Dec 6, 2018

The sql in ea52d69#diff-90d6afcb7795c268b727e72e43d372f0R110 is a problem. I really dont want to make sql harder to read/write, given how error prone it already is.

Is there a tag to disable ocamlformat for certain blocks or similar?

@IanConnolly
Copy link
Contributor Author

@pbiggar couple of things:

  • Just added a script to reformat all of the files, so reformatting is as simple as rebasing off master, interactively dropping the single commit containing all the formatting changes, and running the script
  • I found the magic incantation to avoid the string literals being borked
  • There's a [@@ocamlformat option=val] pragma for both files and expressions if you want to turn on/off a particular formatting type more locally than the whole project. For the string literal one above I did global though.

Log.infO "Libexecution" ~data:"Initialization Complete";
has_inited := true

else Caml.print_endline "Libexecution Initialization Begins" ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my. Look what this found!

@@ -0,0 +1 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's it doing here?

(Also, why do we have an empty file?)

| F (_, PVariable c), F (_, PVariable n) ->
renameVariable c n e
| _ ->
(*
* For now, only allow if all variables in the replaced
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is weird.

| Some (c, n) -> renameVariable c n body
| _ -> body
match
pairCurrentAndNew
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we able to not split match exprs?

| FeatureFlag (msg, cond, a, b) ->
[PFFMsg msg; PExpr cond; PExpr a; PExpr b]
| Match (matchExpr, cases) ->
(* We list all the descendents of the pattern here. This isn't ideal,
(* We list all the descendents of the pattern here. This isn't ideal,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the things I liked about janestreet was the lack of this indent. Is it possible to kill the indent?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm, I think I'll just get used to this one.

@pbiggar
Copy link
Member

pbiggar commented Dec 7, 2018

Perhaps the path here is to merge this:

  • without the actual change commit
  • with the enforcement disabled via commenting

and the we can turn it on later (I'm not sure when exactly later is though, given there's always work in progress)

@IanConnolly
Copy link
Contributor Author

@pbiggar two PRs are merged, and this is rebased

@IanConnolly IanConnolly merged commit 95c087a into master Dec 7, 2018
@pbiggar pbiggar deleted the chores/enable-ocamlformat branch December 8, 2018 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants