What are some libraries you almost always use?

If it’s subjective then why do you say the API is hard to use ? It brings nothing to the discussion and becomes a baseless claim which is precisely the start of myth building.

Personally I don’t think hard and easy are subjective. It can be contextual but for each context you can specify criterions to assess the level of hardness which is precisely what I did in my reply to demonstrate why I think it’s not for the context of the working ocaml programmer.

3 Likes

Instead of ranting against Cmdliner

you can try some alternatives in opam.

I think Daniel has a style, and his style can be recognized in all his libraries.
Either you like his style of API design and heavy use of types, either you don’t.

The newcomer alternative:

My personal hack, for fast development of executables with a CLI that must be correctly used, but still easy to change:

Conservative people still use this one:
https://caml.inria.fr/pub/docs/manual-ocaml/libref/Stdlib.Arg.html
I think that once you have a working example, Arg is bearable.

If you don’t like any of those, then write your own, publish it in open-source and contribute to the fantastic and always changing OCaml ecosystem bazaar. :smiley:

2 Likes

I’d be curious where you see heavy use of types ?

I do use types to design APIs because it is a strong organizing and compositional tool.

But most of the time I eschew more advanced type level programming tricks (e.g. phantom types) because they tend to hamper usability (e.g. unreadable error messages, unflexible code motion, etc.) for little returns.

That’s an interesting comment because I thought about it but forgot to mention it in my assessment above. Like Cmdliner when I need to use Arg I go back to a previous example, cut and paste it and start from there…

2 Likes

There are multiple things one does when one “uses an API.”

One thing that is somewhat difficult is to figure out how to use multiple functions one-after-the-other to do what you want. Wait, how do I make this arg optional? Uh, the type system says I have only partially applied something?

One thing that is somewhat easy is to make sure you haven’t forgotten something, you haven’t mixed up two functions, etc. In short: that you haven’t misused the library. This is somewhat easy because you can lean on the type checker! The library defines a tightly typed playground within which there is one way to do one thing and anything else will get you a compiler error.

There are some libraries that are much easier on the first part (where you can write code that compiles easily) but much harder on the second part (where you can write code that fails at runtime in difficult to debug).

4 Likes

Boy, this thread’s gone really off-topic, but hey, at least I get to learn about great stuff like this! Looking forward to this!

I don’t use Dune

I’m glad not being alone :slight_smile:

Great and useful information. I appreciate your answers, guys!

2 Likes