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

Type-checker rejects cyclic type abbreviation even though -rectypes is activated #6007

Closed
vicuna opened this issue May 6, 2013 · 2 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented May 6, 2013

Original bug ID: 6007
Reporter: @fpottier
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:18:50Z)
Resolution: not a bug
Priority: normal
Severity: minor
Platform: Linux, MacOS
Version: 4.00.1
Category: typing
Child of: #5343
Monitored by: @gasche

Bug description

This problem concerns ocamlc -rectypes. If I define a cyclic type
abbreviation foo as follows, it is accepted:

type 'a foo = 'a foo list (* accepted *)

However, I wish to abstract away the type list, so I place this
definition in the body of a functor, which expects list as an
argument. Then, the definition is rejected by ocaml 4.00.1:

module M (X : sig type 'a list end) = struct
type 'a foo = 'a foo X.list
(* accepted by ocaml 3.11.2; rejected by ocaml 4.00.1 *)
end

Is this a bug or is there a good reason to reject this definition?
Thanks!
Francois.

File attachments

@vicuna
Copy link
Author

vicuna commented May 6, 2013

Comment author: @garrigue

There is indeed a good reason: we don't know whether X.list is contractive,
and if it were not, foo would not be well-founded (leading to a potential
unsoundness).
See #5343 for details.

@vicuna
Copy link
Author

vicuna commented May 6, 2013

Comment author: @fpottier

Hi Jacques,
I have looked at #5343. I understand. Indeed, unless we allow declaring
that an unknown type constructor is contractive, I do not see how
to allow this code. Too bad... Thanks for the quick reply.

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