Feedback / Help Wanted: Upcoming OCaml.org Cookbook Feature

Ok, thanks. There are many tasks waiting for a recipe… I will surely take some time to contribute. Note: the page says something about a « cookbook section of the CONTRIBUTION.md » which doesn’t exists yet.

I guess that the Database section should provides SQLite, Postgress, MySql, and multi-database option. (Caqti and Petrol are multi-database… no need to duplicate their recipes)

The plan seems to follow the Rust Cookbook (the Earth distance between two points is typical !) I guess it can be adapted (no mention of ZIP… but tar.gz is proposed. However camlzip handle the former not the last one. And ZIP has more usages - docx, jar, …)

1 Like

There appears to already be an issue raised suggesting that a central list of who has volunteered for what would be helpful. In the absence of that I’ll mention here that if nobody else has yet, I’ll take a look at the “command-line parsing” items over the next few days.

2 Likes

I would greatly appreciate some recipes on concurrency. I clicked on the “create and await promises” link and it takes me to an empty page: OCaml Cookbook

2 Likes

The process of writing a cookbook entry seemed quite simple and I’ve had my first attempt reviewed already, so I will have a go at writing some recipes for “create and await promises”. It may take me a few days @zoj613 - it will need an example using Async which I’ve never looked at.

3 Likes

Are there docs on how to run or test the cookbooks against the CI/CD with the yaml meta at the top of the file? I have a PR up for reading csvs which I used dune to get running then reformatted to match the cookbook format. I’m hitting errors in the CI/CD which I’d like to resolve locally if possible for quicker iterations.

I just ended up getting my code-samples working separately from the cookbook and pasting the yaml in the top once I was done :frowning:

That wasn’t ideal because I still wanted to tweak the comments to line up with my code.

I think longer-term the yaml needs to go in its own file (named to match the .ml file?) or be in a comment at the top of the file or some such. Possibly the cookbook code should be its own repo too with tests for expected output etc. That might have value of its own anyway - it could be useful to clone the cookbook repo and hack around on the examples.

2 Likes

Worked it out and I’ll post it here for now in case it helps anyone. It’s pretty straight forward really.

  1. Clone the repo: GitHub - ocaml/ocaml.org: The official OCaml website.
  2. Create a local switch in the root of the project
  3. Activate the switch
  4. Install the dependencies
  5. Run the build command
opam switch create . 4.14.1
eval $(opam env --set-switch)
opam install . --deps-only --with-test --with-doc
opam exec -- dune build @install

It seems in my case the meta data had to be quoted for the build to pass (some other examples I looked at weren’t quoted so this might be a recent-ish change).