Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: -dtypes preserve type variables names from annotations #4319

Closed
vicuna opened this issue Jun 16, 2007 · 3 comments
Closed
Assignees

Comments

@vicuna
Copy link

vicuna commented Jun 16, 2007

Original bug ID: 4319
Reporter: eaubin
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:07:16Z)
Resolution: fixed
Priority: normal
Severity: feature
Version: 3.10.0
Fixed in version: 4.00.0+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: bartjacobs @ygrek till jm hirokawa

Bug description

Could the -dtypes option preserve the name of type variables in annotations? E.g. I've a function

let discriminate
(disc: ('t,int,'v) discriminable) (xs: 't list): 'v list list = ...

which gets shown as ('d, int, 'e) discriminable -> 'd list -> 'e list list by caml-types-show-type instead of ('t,int,'v) discriminable -> 't list -> 'v list list.

@vicuna
Copy link
Author

vicuna commented Nov 10, 2007

Comment author: @xavierleroy

It's an instance of a more general aspect of the OCaml printer for types, namely that it invents names 'a, 'b, etc, for type variables occurring in types. The infrastructure to record and propagate user-provided names is simply not there. I'm afraid it won't change any time soon, but leave this PR as a feature wish.

@vicuna
Copy link
Author

vicuna commented Sep 7, 2009

Comment author: bartjacobs

Notice that F# does this: it preserves user-provided type variable names in error messages and IDE tooltips. It even issues a warning when it constrains a user-provided type variable, saying something like "the polymorphism of this function is less than what is indicated by the type annotations".

@vicuna
Copy link
Author

vicuna commented Jun 1, 2012

Comment author: @garrigue

In the upcoming ocaml 4.00, type names are kept during type inference, and they should also appear in .annot files.
Whether we should have a warning when instantiating user-named type variables is an open question.
In Standard ML this is an error to instantiate a provided type.
In OCaml type variables are handled just as unification variables, which can be freely instantiated, but since 3.12 one can also use explicitly polymorphic type annotations to prohibit instantiation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants