VOCaml: add and remove type annotations in VS Code

Hi!

I’m happy to announce a VS Code extension VOCaml (GitHub release) where I’ll be putting my OCaml coding helpers. Currently, it has three commands:

  • VOCaml: Add Type Annotations inserts type annotations around let bindings.
  • VOCaml: Remove Type Annotations removes type annotations from let bindings.
  • VOCaml: Visit File from Current Line triggers a Quick Open dialog populated with a file and line number retrieved from the line at cursor position.

VOCaml is a companion to ppx_minidebug, but it can be used for its own merits. It has some limitations, report issues if you try it!

Thanks,
Lukasz

3 Likes

ocamllsp has a code action to do type annotation. I believe that using it could simplify your code a little bit.

Ah it has both actions “Type annotate” and upcoming “Remove type annotation”! I wasn’t aware. I could maybe retire this extension. Except, it enhances the functionality for selections – it annotates multiple let-bindings at once. The code action treats a selection as indicating the expression to annotate.

Thank you!

The code action Type annotate also does not type-annotate function bindings in a nice way, so there’s still raison d’etre for VOCaml…

Hi @lukstafi,
I have take a look into your solution, which is related to my current work.
I’ve been working on improving type annotations in ocaml-lsp. The problem with functions is actually a bit harder then I expected, so for now it will probably be disabled. You can find the discussion and explanation here:

Best,
Rafal

2 Likes

A new version of VOCaml – 1.1.1 is out (Marketplace). Multiline types work now, also labeled arguments (and optional without defaults), unit value pattern.