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

polymorphic variants with ocamlc #8154

Closed
vicuna opened this issue May 23, 2003 · 1 comment
Closed

polymorphic variants with ocamlc #8154

vicuna opened this issue May 23, 2003 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented May 23, 2003

Original bug ID: 1695
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Some problems using variants in compilation mode:

let l = [B] @ [A];;

val l : _[> A | B] list = [B; A]

is what I am expecting in the top level loop

but the compilation with ocamlc give:

The type of this expression, _[> A | B] list,
contains type variables that cannot be generalized

Is it normal?
If yes, is there some documentation?

@vicuna vicuna closed this as completed May 23, 2003
@vicuna
Copy link
Author

vicuna commented May 23, 2003

Comment author: administrator

From: etienne.closse@athys.fr

Some problems using variants in compilation mode:

let l = [B] @ [A];;

val l : _[> A | B] list = [B; A]

is what I am expecting in the top level loop

but the compilation with ocamlc give:

The type of this expression, _[> A | B] list,
contains type variables that cannot be generalized

Is it normal?
If yes, is there some documentation?

This is perfectly normal: the _ in the above type denotes a
non-generalizable type variable in the type of l. This is allowed at
toplevel, but not in compiled modules, if you don't provide a .mli.
For documentation on non-generalizable type variables, look the FAQ
about "value restriction".

However, there is a good news: in the next version of ocaml, the above
example would avoid the value restriction, and you would get a type
without _, and as result no problem with compilation.

Jacques Garrigue

@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant