Tarides Logo
OCaml-related diagram or code.

Full blown productivity in VSCode with OCaml

Pizie Dust

Software Engineer

Posted on Fri, 28 Feb 2025

Happy New Year, OCamlers! 🎉 As we usher in another year, we have something special to celebrate — a New Year's gift that promises to make your coding experience even better! We have been working on exciting new features in VSCode designed to boost productivity, streamline workflows, and make your development journey smoother and more enjoyable.

For users of Emacs, we have a brand new emacs mode for interacting with the lsp server that will make your coding experience as enjoyable as it should be. Check out the Discuss announcement at Release of ocaml-eglot 1.0.0 and the project repository at ocaml-eglot.

Without further ado, let's "unwrap" 🎁 these features for your viewing pleasure.

1. Type of Selection

This feature enhances code comprehension by allowing you to grow or shrink the selection to view updated types at different levels of granularity. You can adjust the verbosity of the type information to suit your needs, providing either a concise or detailed view. This information can be accessed conveniently through the default hover pop-up or via a dedicated output panel, making it adaptable to your workflow.

Command name: Get the Type of the Selection

  • Command shortcut: Alt + T
  • Grow Selection: continously press Alt + T
  • Shrink Selection: Alt + Shift + T
  • Add Verbosity: Alt + V

Using Alt+T to get the type of Selection

Using a dedicated Output Panel

In the settings/preferences of the ocaml platform extension, you can toggle an option to display the results of type selection in a dedicated output panel.

Toggling the settings to use a dedicated output panel

Type Selection with results displayed in a dedicated output panel

2. Search by Type or Polarity

Looking for functions or values that match a specific type? The Search by Type/Polarity feature let's you input a type signature, e.g., int -> string or a polarity -int +string, and then it fetches all matching functions and values across your project.

Command name: Search a value by type or polarity

Command shortcut: Alt + F

  • Search by Type Searching a value by it's type

  • Search by Polarity Searching a value by it's polarity

3. Construct Typed Holes

This feature let's you construct possible values for a given typed hole.

Command name: List values that can fill the selected typed-hole

Command shortcut: Alt + C

Construct functionality to list values that can fill the selected typed-hole

This feature also comes with a configurable option that allows it to construct values for the next typed hole automatically.

Setting to toggle construct to be conducted for the next typed hole automatically

Performing construct with chaining turned on

4. Jump to a specific Target

Traditional navigation, while it works, falls short when it comes to navigation in OCaml. This feature provides a seamless way to jump to specific targets which are closest to your cursor in the source code. For example, a large match construct and you could jump from one case to the next effortlesly.

Command name: List possible parent targets for jumping

Command shortcut: Alt + J

At this point, we support the following targets:

  • Modules
  • Functions
  • Let statements
  • Match statements
  • Match cases (previous and next)

Jumping to a specific target

5. Navigate Typed Holes

This feature let's you navigate to typed holes.

Command name: List typed holes in the file for navigation

  • As you move through the list with your arrow keys, the cursor jumps to the typed hole to give you a preview. When you make a selection, the cursor stays there.

Navigating to different typed holes

  • If you toggle the Navigate

Setting to automatically perform construct after jumping to a typed hole

Automatically performing construct after navigating to a typed hole

  • If you don't feel like jumping to a typed hole yet, just hit Esc and your cursor will portal back to it's original position.

Pressing the Escape key to stop operations and return back to the origin cursor position

Hope you are excited to try out these new features. It is our wish that you have a much better and smoother experience while coding OCaml in VsCode.

Please feel free to open issues if you discover a problematic behaviour:

You can connect with Tarides on Bluesky, Mastodon, Threads, and LinkedIn or sign up for our mailing list to stay updated on our latest projects. We look forward to hearing from you!

Open-Source Development

Tarides champions open-source development. We create and maintain key features of the OCaml language in collaboration with the OCaml community. To learn more about how you can support our open-source work, discover our page on GitHub.

Explore Commercial Opportunities

We are always happy to discuss commercial opportunities around OCaml. We provide core services, including training, tailor-made tools, and secure solutions. Tarides can help your teams realise their vision