Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007866OCamltypingpublic2018-10-25 09:112018-10-25 16:43
Assigned To 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0007866: Optional argument type not printed
DescriptionIn some cases the type of an optional argument cannot be printed.

    # type 'a opt = 'a option;;
    type 'a opt = 'a option

    # let foo (type a) ?(x : a opt) () = ();;
    val foo : ?x:<hidden> -> unit -> unit = <fun>

This is because the type of the argument becomes `'a opt` instead of `'a option`. I suspect that the proper fix is to represent the types of optional arguments as `'a` instead of `'a option`.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
frisch (developer)
2018-10-25 09:42

> cannot be printed.

I assume that the trouble is that the printer does not have access to the environment in order to unify the argument type with 'a option in order to extract 'a. Is that right? Could one use the environment provided by wrap_printing_env?

> I suspect that the proper fix is to represent the types of optional arguments as `'a` instead of `'a option`.

Do you mean splitting:

  | Tarrow of arg_label * type_expr * type_expr * commutable
  (** [Tarrow (Nolabel, e1, e2, c)] ==> [e1 -> e2]
      [Tarrow (Labelled "l", e1, e2, c)] ==> [l:e1 -> e2]
      [Tarrow (Optional "l", e1, e2, c)] ==> [?l:e1 -> e2]

in two constructors (or putting the first type_expr "under" the three constructors), so that the first type_expr can be given a different meaning?
lpw25 (developer)
2018-10-25 11:04

> Is that right?

Essentially, although I would phrase it more in terms of wanting type printing to work without needing to perform invasive operations like unification on the types.

> Do you mean[...]?

I had in mind making the first type_expr part of the label type, and giving it a slightly different meaning in the optional case. It just seems a cleaner representation to me, but its probably a fairly invasive change.

- Issue History
Date Modified Username Field Change
2018-10-25 09:11 lpw25 New Issue
2018-10-25 09:42 frisch Note Added: 0019423
2018-10-25 11:04 lpw25 Note Added: 0019424

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker