Skip to content

Install

You need opam, OCaml’s package manager, and OCaml 5.5 or later. wiretype brings dune, the build tool, with it.

Terminal window
brew install opam
Terminal window
opam init

Answer yes when it offers to set up your shell. This installs the latest OCaml, which takes a few minutes. Then let this terminal see it – a new terminal does by itself:

Terminal window
eval $(opam env)
Already had opam?

Check ocaml -version. If it is older than 5.5, make a switch – an environment of its own – with the latest OCaml:

Terminal window
opam switch create wiretype ocaml-base-compiler
eval $(opam env)
Terminal window
opam repo add hypha https://github.com/hyphatech/opam-repository.git
opam install wiretype ppx_wiretype
Package What it is
wiretype descriptions: reading, writing, bounds, kinds, schemas; links Ptime, Mtime and Uuidm alone
ppx_wiretype [@@deriving wiretype], which writes a type’s description

A program that only writes its descriptions by hand needs wiretype alone.

A program names the libraries it uses in its dune file, and the deriver as a preprocessor:

(executable
(name main)
(libraries wiretype)
(preprocess (pps ppx_wiretype)))

A description that names a time or a UUID – a Ptime.t, an Mtime.Span.t or a Uuidm.t – needs that library in libraries too: ptime, mtime or uuidm.

Terminal window
$ ocaml -version
$ opam list wiretype ppx_wiretype

The first says 5.5 or later. The second lists both packages with a version, not --, under Installed.

For completion, types on hover and errors as you type, install the language server, then the OCaml Platform extension in VS Code – or the OCaml support of your editor:

Terminal window
opam install ocaml-lsp-server

The quick start writes a first description, next.