package dkml-dune-dsl-show

  1. Overview
  2. Docs
An interpreter for the embedded DSL of Dune that shows the DSL as a real Dune file

Install

Dune Dependency

Authors

Maintainers

Sources

dkml-dune-dsl-0.1.1.tbz
sha256=a7fe720d17809079b5430f382497f0c138159dc67e94d74bbeab35a4094344ed
sha512=a43b94f0b4708f0a40942ff23c850a466501abbd39ca1bc2ddf0743be2d8c4793ccf2d8a2b64a326752c4f425b62abc51f51af29fa3ba5b2e2f44b31c1ef483f

Description

Published: 03 Apr 2023

README

dkml-dune-dsl

A mini-language (DSL) for Dune files embedded in OCaml that produces readable, valid Dune include files. The mini-language closely matches the structure of a regular Dune file, and because it is embedded in OCaml you get OCaml type-safety and the power of your favorite OCaml IDE as you write your Dune files.

The Dune DSL uses a tagless final design so your Dune DSL can be interpreted in a variety of ways that are independent of Dune itself. The standard dkml-dune-dsl-show interpreter allows all of the Dune string values (executable names, rule targets, etc.) to be parameterized from external JSON files. That lets you produce many similar executables, libraries or assets using the same Dune logic without repeating yourself DRY.

The documentation is at https://diskuv.github.io/dkml-dune-dsl/dkml-dune-dsl/index.html

Once installed (see the documentation) you will be able to write DSL expressions like:

open DkmlDuneDsl

module Build (I : Dune.SYM) = struct
  open I

  let res =
    [
      rule
        [
          target "{{{ name }}}.txt";
          action
            (with_stdout_to "%{target}"
              (echo [ "{{{ age }}}" ]));
        ];
    ]
end

that are run over the parameters in a JSON file:

{
  "param-sets": [
    {"name": "batman", "age": 39},
    {"name": "robin", "age": 24}
  ]
}

You can do also do aggregation or, if you are really adventurous, define your own interpreter. Even if you don't use parameterization you get things you take for granted with OCaml: type-safety, auto-complete and let constants.

Examples and Testing

The examples are available in the examples/ folder. Since Dune is the authority on whether Dune DSL is producing correct output, each example includes a test that checks the output of Dune.

For now the process is when a new bug is found then an existing example is expanded or a new example created.

Dependencies (9)

  1. sexp_pretty >= "v0.14"
  2. menhir >= "20180528"
  3. mustache >= "3.1.0"
  4. fmt >= "0.9.0"
  5. ezjsonm >= "1.3.0"
  6. astring >= "0.8.5"
  7. dkml-dune-dsl = version
  8. ocaml >= "4.12.1"
  9. dune >= "2.9"

Dev Dependencies (2)

  1. odoc with-doc
  2. alcotest >= "1.5.0" & with-test

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.