$ show ocaml/dune
Dune is a composable build system and package manager for OCaml and related languages. In production, it parses `dune`/`dune-project`/`dune-workspace` configuration files, generates build rules for libraries, executables, foreign stubs, tests, documentation, and integrations (Melange, js_of_ocaml, wasm_of_ocaml, Rocq/Coq, ctypes, menhir, mdx), then executes those rules with an incremental engine featuring memoization, file watching, sandboxing, caching, promotion, and an RPC-accessible watch mode. The main entry point is the `dune` CLI (`bin/main.ml`), with subcommands grouped under `bin/`: `build`, `exec`, `runtest`, `fmt`, `promote`, `describe`, `pkg`, `trace`, `rpc`, `ocaml`, and `rocq`. Dune also includes an experimental package manager (`dune pkg`) that solves opam dependency formulas, fetches sources, and writes lock directories.
The LLM identified 5 files worth highlighting for reuse:
A type-safe heterogeneous map keyed by type identity, allowing arbitrary typed values to be associated with keys without central record types. This is a generic utility pattern that can be extracted into any OCaml project needing extensible per-key metadata.
Core incremental computation library powering Dune's rebuild engine. It provides memoized functions with automatic dependency tracking, invalidation, cutoffs, and parallel execution. The design is self-contained and adaptable to any incremental data-flow or caching system, not just build tools.
A lightweight monadic fiber library with cancellation, streams, throttling, and event-bus primitives. It is used by Dune's scheduler for asynchronous process supervision and file watching, and can be reused as a smaller, self-contained alternative to Lwt/Async.
A library for writing configuration and environment-discovery scripts in OCaml instead of autoconf/shell. It queries pkg-config, probes C compiler flags, runs preprocessor tests, and generates config files. Published as a standalone opam package, it is directly reusable by mixed C/OCaml projects.
A low-level RPC protocol implementation over Unix sockets using canonical s-expressions, with buffered IO and long-poll support. This pattern is reusable for building typed client-server IPC layers where wire format stability and backpressure matter.