Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diskuv/dkml-dune-dsl
Embedded DSL for Dune files to do syntax checking, auto-completion and generate dune.inc include files
https://github.com/diskuv/dkml-dune-dsl
Last synced: 8 days ago
JSON representation
Embedded DSL for Dune files to do syntax checking, auto-completion and generate dune.inc include files
- Host: GitHub
- URL: https://github.com/diskuv/dkml-dune-dsl
- Owner: diskuv
- License: apache-2.0
- Created: 2022-10-03T08:04:48.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-18T01:50:18.000Z (about 2 months ago)
- Last Synced: 2024-09-18T05:33:53.562Z (about 2 months ago)
- Language: OCaml
- Homepage: https://diskuv.github.io/dkml-dune-dsl/dkml-dune-dsl/index.html
- Size: 551 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
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](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself).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:
```ocaml
open DkmlDuneDslmodule Build (I : Dune.SYM) = struct
open Ilet res =
[
rule
[
target "{{{ name }}}.txt";
action
(with_stdout_to "%{target}"
(echo [ "{{{ age }}}" ]));
];
]
end
```that are run over the parameters in a JSON file:
```json
{
"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/](./examples/README.md) 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.