caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Mark Bradley <barkmadley@gmail.com>
To: "Richard W.M. Jones" <rich@annexia.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] OCaml code style and syntax checking
Date: Wed, 5 Jul 2017 00:21:49 +1000	[thread overview]
Message-ID: <CAFBPYtzsvQVV3L3oizu-j_UPmj9GRqJA35NHUmXWHq6KC7x77g@mail.gmail.com> (raw)
In-Reply-To: <20170704140334.GB18152@annexia.org>

[-- Attachment #1: Type: text/plain, Size: 2020 bytes --]

Another idea that will get you part of the way there is to use refmt to
automatically format the OCaml files to standard layout.

This would cover 3 out of the 4 criteria because:

1. it automatically indents
2. it always reduces parentheses where it can
3. it automatically converts begin and end to parentheses.

The 4th criteria could potentially be caught using grep.

It's worth an experiment to see if you like the style of code generated by
refmt for OCaml. It certainly does a better job at formatting reason code
from my limited experiments (it doesn't seem to like vertical white space
when generating OCaml, whereas it will include it if you covert the file to
reason, testing version 1.13.5 as of writing).


On 5 July 2017 at 00:03, Richard W.M. Jones <rich@annexia.org> wrote:

> On Tue, Jul 04, 2017 at 03:01:28PM +0100, Richard W.M. Jones wrote:
> > I have a need to make automated stylistic and syntax checks to
> > a large amount of OCaml code.  The sort of rules would be:
> >
> >  - Check that indentation is used, and used consistently.
> >
> >  - Excessive use of parentheses where not needed.
> >
> >  - Use ( .. ) instead of begin .. end.
> >
> >  - Flag uses of various Obj.* and unsafe_* functions.
> >
> > It seems to me that some of these could be tested with either camlp4
> > or ppx.  I think if we allowed the checker to go back to the original
> > code (eg to see if the parser parsed as block as '(' or 'begin'),
> > it might be able to check all of these things.
> >
> > Anyway, before I start on it I'm wondering if anyone has ever
> > looked at doing this kind of thing?
>
> Now that I actually formulate the right search terms, I see
> that ocp-lint exists :-/
>
> Rich.
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>



-- 
-barkmadley
sent from an internet enabled device
http://barkmadley.com

[-- Attachment #2: Type: text/html, Size: 3128 bytes --]

  reply	other threads:[~2017-07-04 14:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-04 14:01 Richard W.M. Jones
2017-07-04 14:03 ` Richard W.M. Jones
2017-07-04 14:21   ` Mark Bradley [this message]
2017-07-11 12:22 ` Sébastien Hinderer
2017-07-11 13:03   ` François Bobot
2017-07-11 13:11     ` Sébastien Hinderer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFBPYtzsvQVV3L3oizu-j_UPmj9GRqJA35NHUmXWHq6KC7x77g@mail.gmail.com \
    --to=barkmadley@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=rich@annexia.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).