Runtime Types.

Alain Frisch

It is often useful to get access to types at runtime, in order to implement generic type-driven operations. A typical example is a generic value pretty-printer.

Unfortunately, the OCaml compiler does not keep type information at runtime. At LexiFi, we have extended OCaml to support runtime types. This extension has been in use for years and is now a key element in many of our interesting components, such as our automatic GUI framework (which derives GUIs from type definitions) or our high-level database layer (which derives SQL schema from type definitions, and exposes a well-typed interface for queries).

I’m now proposing to include a similar extension into OCaml itself. I’ve described this proposal at the last meeting of the Caml Consortium. You can download the presentation where I describe the proposal:

Feel free to ask questions or comment on the proposal!