package containers
A modular, clean and powerful extension of the OCaml standard library
Install
Dune Dependency
Authors
Maintainers
Sources
containers-3.15.tbz
sha256=92143ceb4785ae5f8a07f3ab4ab9f6f32d31ead0536e9be4fdb818dd3c677e58
sha512=5fa80189d0e177af2302b48e72b70299d51fc36ac2019e1cbf389ff6a7f4705b10089405b5a719b3e4845b0d1349a47a967f865dc2e4e3f0d5a0167ef6c31431
doc/containers.codegen/Containers_codegen/index.html
Module Containers_codegen
Source
Code generators
The code generator library is designed to be used from a build system (for example, from dune
) to generate efficient code for features that are harder to provide at runtime.
The idea is that the build system should invoke some OCaml script that depends on containers.codegen
; the script uses the DSL below to describe what code to generate (e.g. a description of a bitfield type) and emits a .ml
file (and possibly a .mli
file).
For example, the build script might contain:
module CG = Containers_codegen
let () =
let module B = CG.Bitfield in
let b = B.make ~name:"t" () in
B.field_bit b "x";
B.field_bit b "y";
B.field_bit b "z";
B.field_int b ~width:5 "foo";
CG.emit_file "foo.mli" [B.gen_mli b];
CG.emit_file "foo.ml" [B.gen_ml b];
()
and this will produce foo.ml
and foo.mli
with a bitfield containing x
, y
, and z
.
emit_file file cs
emits code fragments cs
into the given file at path file
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page