Learn how to solve CodeCrafters challenges in OCaml
./your_program.sh
) will run your code using these tools. It will look something like this:
src/
directory.src/main.ml
is the entry point for your OCaml program..ml
files in the src/
directory. The test runner will include them when building and running your code.
For example, if you add a file at src/foo.ml
, you can reference it in main.ml
like this:
Specify dependencies
dune-project
and dune
files.For example, to add the yojson
library for handling JSON, first update dune-project
as follows:dune
file to include yojson
as a library:Install dependencies
.opam
file from dune-project
before installing dependencies.First, run this command to update the .opam
file:.ml
file, dune build
will exit with an error. This is okay — it’ll still update the .opam
file (required for the next step).Use dependencies
yojson
library: