package dkml-dune-dsl

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

dune files are the main part of Dune. They are used to describe libraries, executables, tests, and everything Dune needs to know about.

Dune files

dune files are the main part of Dune. They are used to describe libraries, executables, tests, and everything Dune needs to know about.

The official documentation is on the Dune website.

Argument Handling

Many Dune expressions have a list of strings as arguments. For example, the SYM.libraries expression declares the list of libraries that an executable needs. Use one of the following variants to tell the expression interpreter how to process your string argument:

  • `S "something" is a literal string
  • `Split "something1 something2 ..." is zero or more strings split by whitespace (roughly speaking). The formal splitting algorithm follows the Lexical conventions of s-expression for identifying atoms in a list.

All the expressions below are equivalent:

(libraries [`S "lib1"; `S "lib2"; `S "lib3"]) (libraries [`Split "lib1 lib2 lib3"]) (libraries [`S "lib1"; `Split "lib2 lib3"])

Why use `Split? Besides saving a bit of typing for long lists, a `Split is the right choice when your interpreter supports parameterized strings. For example, if you were using the "dkml-dune-dsl-show" interpreter and configured it with a JSON parameter file, you could use `Split "{{#libraries}} {{library}} {{/libraries}}" and the "dkml-dune-dsl-show" interpreter would:

  1. concatenate all of the libraries JSON array from the JSON parameter file into a space separated list of libraries
  2. `Split would then split the space separated list of libraries into the individual libraries.
module type SYM = sig ... end

The module type for an embedded domain specific language (eDSL) that describes a Dune file.

OCaml

Innovation. Community. Security.