Commit Graph

87 Commits (master)

Author SHA1 Message Date
Jacques Garrigue 603506aa34
Add injectivity annotations (#9500) 2020-06-15 13:51:50 +02:00
Thomas Refis 8e928caea7
a better representation for modules with no name (#8908) 2019-10-09 14:15:37 +01:00
Jeremie Dimino 2d31ebfc8b Add support for [@@immediate64]
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2019-09-24 07:56:15 +01:00
Gabriel Scherer c7b0f4d71d typing/oprint: linear implementation of the functor printing heuristic 2019-09-04 21:18:17 +02:00
Gabriel Scherer 1ba9dce47f typing/oprint: improve printing of functor arguments
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
2019-09-04 21:18:16 +02:00
Gabriel Scherer 331b322ab5 typing/oprint: rework printing of functor arguments
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.
2019-09-03 17:48:13 +02:00
Gabriel Scherer 071bae4c5f typing/oprint: [minor] improve printing of empty signatures 2019-09-03 11:44:21 +02:00
Florian Angeletti 2bd33ee515
Merge pull request #8906 from Octachron/functor_arrow_associativity
Print parentheses in (A->B)->C
2019-09-02 17:51:17 +02:00
Florian Angeletti 740baf0317 Print parentheses in (A->B)->C 2019-09-02 15:16:47 +02:00
Florian Angeletti 6032e9cf49 oprint: add break hint after functor args 2019-08-29 14:48:46 +02:00
Mekhrubon Turaev 407d650f6e Printing additional info about types mismatch during compilation error. 2019-07-30 09:51:02 +01:00
Andrew Litteken d4ef2eecea Custom Exception Handlers at toplevel (#8594)
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
*)
```
2019-04-14 15:38:27 +02:00
Leo White 403003cad5 Add support for "let" operators 2018-11-27 13:30:55 +00:00
alainfrisch 0d968e357b Move variable printer to Pprintast
- 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).
2018-11-06 13:12:54 +01:00
alainfrisch 74b24580ca Fix printing of type variables with a quote on 2nd character
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.
2018-11-06 13:12:54 +01:00
Florian Angeletti ea9c493f99 oprint: tweak printing for polymorphic variants 2018-08-15 19:32:48 +02:00
Armael f8ceab6308 Printtyp: minor refactoring of Path.t printing functions (#1988)
* 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
2018-08-14 15:32:05 +02:00
Florian Angeletti 349db3d869
PR#6416 et al.: injective mapping between identifiers and printed names (#1120) 2018-06-26 22:03:45 +02:00
David Allsopp b5d1929e87 Whitespace and overlong line fixes. 2018-06-14 15:15:34 +01:00
Nicolás Ojeda Bär 1c262ad9fa Fix toplevel printing of -0. 2018-03-30 22:26:35 -04:00
objmagic 0993cd9ba9 Support empty variants (#1546)
* Allow empty variants.
* Update manual and ocamldoc.
2018-03-06 10:48:16 +09:00
Florian Angeletti 588c23117b Merge pull request #1231 from Octachron/hello_κόσμος
Toplevel: only escapes bytes and not strings
2017-09-13 23:24:24 +02:00
octachron 2e6a78aa18 toplevel: only escapes bytes and not strings
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.
2017-09-12 22:28:18 +02:00
Leo White d41c41c172 Add private extensible variants 2017-09-11 13:29:56 +01:00
Florian Angeletti 7d671fc1d1 M.(::) syntax and printing exotic lists in the toplevel. (#1247) 2017-08-11 10:10:39 +01:00
Fabrice Le Fessant 53c9c500bc Strip big strings in toplevel (#1058) 2017-05-11 13:57:08 +02:00
Valentin Gatien-Baron 45d0fd61b3 fix a problem where short-paths is not working for some polymorphic variant types 2017-01-02 14:52:24 -05:00
Damien Doligez d5a6e50ebe GPR#606: add unboxed types 2016-07-21 13:51:46 +02:00
alainfrisch 7542c34f1d Correctly print declarations of the (::) constructor. 2016-03-30 14:58:15 +02:00
alainfrisch 502e4f9336 More warnings when compiling the compiler. 2016-03-15 22:46:35 +01:00
Damien Doligez 5401ce8473 Update headers for the new license.
Remains to be done: remove all headers in testsuite/tests.
2016-02-18 16:59:16 +01:00
Will Crichton 50dd38d4b6 Add support for immediate attribute 2016-02-02 11:45:07 +00:00
Gabriel Scherer 54e039901e GPR#42: Add simpler functor type syntax
(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
2015-10-25 16:24:47 +00:00
Alain Frisch a21eaeaa40 GPR#254: @ocaml.arg_on_literal_pattern attribute on constructors
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
2015-10-15 12:30:10 +00:00
Jérémie Dimino e982d6906e Update printing of externals
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16457 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-10-06 10:58:25 +00:00
Jérémie Dimino be482e40d5 Update printing of externals with [@unboxed] or [@untagged] attributes
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16383 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-08-25 16:18:48 +00:00
Jérémie Dimino a700f40252 Update printing of nonrec types
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15924 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-03-13 11:09:19 +00:00
Jacques Garrigue 5adbb67a45 PR#6648: show_module should indicate its elision (add Osig_ellipsis to outcometree)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15573 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-11-10 09:09:23 +00:00
Alain Frisch e3ad818fb5 Reintegrate-merge constructors_with_record5 branch.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15556 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-10-14 15:51:30 +00:00
Jacques Garrigue b56dc4b3df PR#5584: merge open extensible types, extension-patch-4.0.2
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14737 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-05-04 23:08:45 +00:00
Alain Frisch d416414ccd Adapt printer.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/constructors_with_record2@14548 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-04-07 12:42:49 +00:00
Gabriel Scherer 9e410c0cfe Shorten syntax for functor signatures (patch by Thomas Gazagnaire)
```
(* Optional naming of parameter implementation *)
module type X = functor (X:S) -> ...
module type X = functor (_:S) -> ...

(* shortening of functor module signatures *)
module type F = functor (X:S) -> functor (Y:S) -> ...
module type F = functor (X:S) (Y:S) -> ...
```

For consistency reasons, this commits also add shortening of functor implementations:

```
(* shortening of functor implementations *)
module F = functor (X:S) -> functor (Y:S) -> ...
module F = functor (X:S) (Y:S) -> ...
```

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14474 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-03-20 15:21:00 +00:00
Jacques Garrigue 3b4d7cf63b Merge module-alias branch (cf. PR#6063)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14394 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-01-10 07:53:33 +00:00
Jacques Garrigue cfa350c31a merge generative functors
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14365 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-12-17 03:52:50 +00:00
Jacques Garrigue 97899f37ca Support module aliases.
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
2013-09-29 07:22:34 +00:00
Damien Doligez 7844495624 Merge branch 4.01 from branching point to 4.01.0+rc1
Command line used:
  svn merge --accept postpone -r 13776:14055 $REPO/version/4.01 .


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14060 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-09-04 15:12:37 +00:00
Alain Frisch ecb088015f Rename Pcty_fun to Pcty_arrow (and idem in Types, Typedtree, Outcometree) to be coherent with Ptyp_arrow.
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/extension_points@13536 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-04-16 08:59:09 +00:00
Alain Frisch e2729b2715 Replace commly used format strings into simple calls to format functions, to improve performance of .annot file generation.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13072 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-11-07 10:50:14 +00:00
Damien Doligez def31744f9 remove all $Id keywords
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13013 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-10-15 17:50:56 +00:00
Xavier Clerc acc19ff167 Removal of unnecessary "rec" clauses (to please warning #39).
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12508 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-05-29 13:41:14 +00:00