|Anonymous | Login | Signup for a new account||2014-10-25 09:07 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0005924||OCaml||OCaml typing||public||2013-02-17 16:48||2013-02-18 01:22|
|Target Version||Fixed in Version|
|Summary||0005924: Adding expressiveness to polymorphic variants|
I'd like to be able to do the kind of functions described here:
let f = function `A -> `C | `B -> `D | x -> x
is typed as:
val f : ([> `A | `B | `C | `D ] as 'a) -> 'a
but a more fine type would be:
val f : [ `A | `B | 'r ] -> [ `C | `D | 'r ]
gasche already told me that it is choice made by the caml developers, but I'm very interested in making such functions. So, if someone can add this expressiveness to the language or explain me why it is really not possible to add this, it would be very helpful.
|Tags||No tags attached.|
This is not strictly impossible to do that, but this requires huge changes in the type system.
* since we would have explicit row variables, you need to introduce a notion of type variable sort
* one would need to add exclusion information on row variables. For instance, with your example,
we would the information that 'r cannot contain any of `A, `B, `C, `D. This is implicit in the type
of f, but it can become hidden in more complex functions, so it would have to be explicit.
* typing of pattern-matching would have to compute remaining cases, which is not trivial in the general case.
For all these reasons there is no plan to introduce something like that at this point.
If you are interested in this subject, you can read papers by Didier Rémy and, more recently, Matthias Blume.
|2013-02-17 16:48||jpdeplaix||New Issue|
|2013-02-18 01:22||garrigue||Note Added: 0008854|
|2013-02-18 01:22||garrigue||Status||new => resolved|
|2013-02-18 01:22||garrigue||Resolution||open => won't fix|
|2013-02-18 01:22||garrigue||Assigned To||=> garrigue|
|Copyright © 2000 - 2011 MantisBT Group|