DEV Community

Yawar Amin
Yawar Amin

Posted on • Updated on

Tagging OCaml packages


Add (tags (org:your-github-username)) to your dune-project file's package stanza.


OCAML's opam package manager has an unfortunately little-known feature calling 'tagging'. This allows you to give 'tags' or 'labels' to your packages and search using those tags. This works a lot like popular blogging platforms, like in fact! And even better, the website package search can already search for tags:

That's an example of searching for the org:erratique tag, which will find all packages by Daniel Bünzli, who meticulously tags his OCaml packages. In fact the org: prefix for tags is specifically reserved for the 'organization' (or person) who publishes the package:

How to tag

If you are using the dune build system, add the tag(s) to your dune-project file's package stanza. E.g.:

 (name dream-html)
 (synopsis "HTML generator eDSL for Dream")
  "Write HTML directly in your OCaml source files with editor support.")
 (documentation "")
 (tags (org:yawaramin))
   (>= 1.0.0~alpha3))))
Enter fullscreen mode Exit fullscreen mode

Of course, you can add multiple tags, e.g. (tags (tag1 tag2 tag3)). Refer to for the documentation.

Make sure you run dune build so that dune regenerates the package's opam file. Now, commit these changes and the next time you publish your package on opam, these tags will appear and be searchable, e.g.


You might have realized that I am specifically recommending adding the org: tag with high priority, because it enables an ad-hoc form of namespacing. The opam registry doesn't auto-enforce namespacing, of course, but you can always appeal to the registry maintainers if you think someone is squatting on your namespace.


Of course, namespacing is not the only benefit–you also improve the searchability of the opam registry by adding this metadata to your projects. For example, if people are looking for web-related projects, they might search for tag:"web" etc. This will benefit the entire OCaml ecosystem. And even better, it's really easy to do.

Top comments (0)