Does there exist a tool which analyzes OCaml programs and suggests some improvements in style and code? In the world of perl there still exists Perl::Critic to avoid bad style.
What I need are some tools which make hints not only about style but also to make things cleaner and to avoid constructs which are not tail recursive in OCaml programs.
Any hints?
I have not used it but a message on the Caml Groups last week mentions Mascot. It looks to be what you are after. I’m not sure about the tail-recursion criteria; the author of the above project doesn’t mention them, but does mention plugin capabilities.
Alternatively, compiling with
-dlinear(forocamlopt[.opt]) will produce linearized code that mentions if the function is a tail-call.-annotalso produces tail-call information, but I cannot find a reference aside from the changelog (it was added in 3.11.0). What way it does tag tail-calls, it doesn’t do the converse, tag non-tail calls (or maybe there is a way?). Below is an example of the output for a function calledsum,produces (amongst much more output),
I think experience is going to be your best bet though. Look through some popular projects (Batteries, for example) to get a feel for style and typical conventions. I don’t think a plugin is going to help you call your accumulator variables
accor continuationscont.