This commit improves the printing of mixed anonymous/non-anonymous
functor signatures from (before)
module type LongFunctor =
functor (X : A) -> B -> functor (Z : C) -> D -> E -> sig end
to (with this commit)
module type LongFunctor =
functor (X : A) (_ : B) (Z : C) -> D -> E -> sig end
The new implementation is closer to the grammar rules, and I find it
easier about.
For example, I was able to implement the long-form-or-short-form
heuristic easily, improving the printing from (before)
module type LongFunctor =
functor (X : A) -> B -> functor (Z : C) -> D -> E -> sig end
to (with this commit)
module type LongFunctor =
functor (X : A) (_ : B) (Z : C) -> D -> E -> sig end
The printing should be exactly the same as with the previous
implementation -- thanks to the help of Florian Angeletti.
fixes#7156
Two new functions exposed:
```ocaml
val to_string_default: exn -> string
(** [Printexc.to_string_default e] returns a string representation of the
exception [e], ignoring all registered exception printers.
@since 4.09
*)
val use_printers: exn -> string option
(** [Printexc.use_printers e] returns [None] if there are no registered
printers and [Some s] with else as the resulting string otherwise.
@since 4.09
*)
```
- The code responsible for printing Syntaxerr errors is moved to the
Parse module (so that it can depend on the variable printer in
Pprintast).
- Pprintast becomes a dependency for a few tools that link some
compiler modules in an ad hoc way (they would better be implemented
in terms of compiler-libs).
Type variables whose name has a single quote as the second character
(such as ' a' or ' a'b) need to be printed with a whitespace after the
initial quote symbol, in order not to be confused with a character
literal.
* Printtyp: minor refactoring of Path.t printing functions
Implement more cleanly and expose the separation of printing in two phases for
Path.t: first, build an outcome tree component (possibly reading printing_env
and updating global state), second, print the outcome tree (without side-effect
apart for printing).
* Expose Oprint.out_ident and remove its duplicata in Printtyp
Escaping strings when printing them in the toplevel has the disadvantage
of mangling unicode text:
```
\# "한글";;
- : string = "\237\149\156\234\184\128"
```
With this commit, strings are not escaped anymore, contrarily to bytes:
```
\# let cosmos = "κόσμος";;
cosmos : string = "κόσμος"
\# Bytes.of_string cosmos;;
- : bytes =
Bytes.of_string "\206\186\207\140\207\131\206\188\206\191\207\130"
```
This new behavior can be disabled dynamically by setting the environment
variable OCAMLTOP_UTF_8 to false
This change is not solely aesthetic: the mangling of unicode string may
contribute to the impression of some OCaml newcomers that Ocaml has no
support for unicode.
(Leo White)
Add support for simple functor types of the form:
S -> T
equivalent to:
functor (_ : S) -> T
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16546 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
to warn when the argument is matches against a constant pattern.
This attributes is applied on predefined exception constructors
which take an purely informational (with no stability guarantee)
message.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16502 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Namely, you can write "module L = List" in signatures,
and avoid have the compiler use directly List when you write L.
See examples in testsuite/tests/typing-modules/aliases.ml
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/module-alias@14196 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02