Join GitHub today
Alias built-in types and pre-defined exceptions in Pervasives #6655
Original bug ID: 6655
The core library http://caml.inria.fr/pub/docs/manual-ocaml/core.html encompasses built-in types, predefined exceptions, and the Pervasives module.
The built-in types and predefined exceptions may be shadowed.
The built-in types and predefined exceptions have associated documentation at the above URL but they don't have a corresponding mli location as they are built-in.
Because of these issues, I propose that Pervasives expose documented aliases for all built-in types and exceptions. This would provide a fixed, standard alias in the event of shadowing and a well-defined reference for these special types and exception constructors. The documentation of exceptions will have to be slightly expanded to mention that they are in fact aliases of the predefined exceptions as exception constructor equality is important but inexpressible in signatures. A link to the above page of the OCaml manual should also be included.
Steps to reproduce
Compare Pervasives to http://caml.inria.fr/pub/docs/manual-ocaml/core.html.
I will produce a patch on demand if desired.
Comment author: @alainfrisch
I agree that it would make sense to have all builin types and exceptions be defined in Pervasives. Leo suggested (in #5072) to have these components really defined in Pervasives, not just as aliases to components in the "empty" environment. To avoid adding a new syntax, one could use:
type int = [%ocaml.builtin "int"]
Otherwise, a less invasive approach is simply to reexport, using "nonrec":
type nonrec int = int
This would be more backward compatible for people who are not opening Pervasives by default. Marking this as suspended for now, but a PR is welcome!