Idea: Standard OCaml runtime type representation

This is what I would love:
(a) A library that integrates with compiler-libs and comes with the OCaml default distribution. It provides combinators that allow you to build runtime type representations (ala Haskell) with any metadata you want attach to those combinators.

(b) The very same library allows you to automatically derive a default runtime type representation using the combinators mentioned in (a). (In this case the metadata would be basically blank). This one should be sufficient for most purposes like debug printing. This is where I differ with @dbuenzli who does not want automatic derivation. Rust has automatic derivation for #[Debug], #[Eq] etc. but you can always override it!

(c) If anybody wants to build more complex, custom runtime representations with metadata by feeding in type definitions via pure OCaml or a DSL (like capnp) to this future external tool (which uses this library) to generate a runtime type representation that is OK. If that is what @dbuenzli wants then that’s cool!

But for me the target is the 80% use case which is (b). Most users will just want to use (b). As long as that is provided, I’m happy.

For me, most of the time (especially newbies) just want to generate equality or debug printing for data structures without wrestling with ppxes. That is the what I want OCaml to get. It’s great if you we build a lovely tower of functionality using (c) eventually. The road to (c) is long.

However, (a), (b) can be achieved fast by looking at repr, refl etc. seeing if the libraries are any good and see if their non-ppx related base code can be incorporated into the Ocaml distribution as a core library. Of course we would need to add automatic derivation of runtime type representations without using the ppx infrastructure. That might require some custom compiler code. Since we don’t have typeclasses this code might need to be ad-hoc. To me the “non-generic” nature of this is OK given the huge benefit this gives the average user and the fact that modular implicits in many years into the future and there exist special case things like Marshalling anyways as a precedent.