What is an example of a good, modern OCaml codebase that I can learn from?

Question is in the title :slight_smile:

4 Likes

I would nominate any project by @dbuenzli : he knows how to write the code, also how to write the documentation. Concretely, maybe cmdliner might be nice to look at. Or fmt.

8 Likes

Also asked in https://www.reddit.com/r/ocaml/comments/sj4htc/what_is_an_example_of_a_good_modern_ocaml/

2 Likes

The “fix” project by Francois Poittier, is also a good choice. I have been hacking on that for the last week, and it’s lovely code. Also powerful ideas and theory there, but really, that isn’t a prerequisite for your question, I’d think. I’s well-written and easy-to-modify: I’m using to hack/hack/hack on Camlp5’s parser-generator, and it’s great fun. And for those who don’t know about the Brzozowski derivative, I highly recommend having a look.

http://gallium.inria.fr/blog/fixin-your-automata/

1 Like

I understand good, but what’s the difference between modern and not?

1 Like

Thanks for the embarassing praise, but I wouldn’t recommend any.

Some of the stuff has been written ages ago when the language, the stdlib and the @dbuenzli were quite different. If you want to follow this advice tend to favour more recent projects (look at the CHANGES.md for the first date of release).

Also this is mostly libraries so it may not be that interesting to look at (there is however this CRUD webapp, but saying I’m happy with the code would be quite a stretch, there’s tons of things to iron out but at some point you have to deliver…).

3 Likes

Modern is a ragbag but if you take it to mean matches the current language capabilities it makes sense.

For example 18 years ago, encoding and using existential types was quite involved, but if you needed them that was “good” and “modern” :joy:. Nowadays, in “modern” code, this is just a GADT existential away.

3 Likes

I wonder nobody mentioned @antron and lambdasoup or dream so far. The new website works that way: https://github.com/ocaml/v3.ocaml.org-server.

Or tyre by @drup.
Or stuff by @hannes & friends in the mirage ecosystem.

6 Likes

oh – and definitively don’t miss Share your crazy OCaml code snippet!

+1 for dream by @antron.

It’s a real pleasure to read and to see the power of just a bunch of types that are glorified functions.

3 Likes