You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 1366 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Put this text into a file and compile it with ocamlc:
class type ['a] eventdesc = object end
type 'a described_event = {ddesc: 'a eventdesc}
[..]
You'll get an error like
File "foo.ml", line 15, characters 38-71:
This method has type 'a described_event which is less general than
'b. 'b described_event
This error message is bad; the problem is actually that the method has
type string described_event.
You got me for almost an hour on that. Before I realized that here,
'a eventdesc is equal to string eventdesc. Why is it so?
Since 'a does not appear in the expension of event desc (< >),
It's binding does not matter.
If the type were simply 'a described_event for all 'a, then the type
would not be less general than the intended type.
Here the problem is more subtle. Due to the value restriction,
eventdesctable has a monomorphic type, and as a result all type
variables appearing in it cannot be generalized. This is what this
message says: 'a is not a generalizable variable. Maybe printing it as
'_a would be more intuitive.
And yes, this is slightly in contradiction with the above explanation:
if 'a does not matter, why can't we generalize it? Well, these unused
variables are a pain anyway. They are only useful if you want to make
an abstract type out of eventdesc, and you will not get a coherent
behaviour otherwise. Actually your program might be accepted in future
versions.
Jacques
The text was updated successfully, but these errors were encountered:
Original bug ID: 1366
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
From: tim@fungible.com
You got me for almost an hour on that. Before I realized that here,
'a eventdesc is equal to string eventdesc. Why is it so?
Since 'a does not appear in the expension of event desc (< >),
It's binding does not matter.
Here the problem is more subtle. Due to the value restriction,
eventdesctable has a monomorphic type, and as a result all type
variables appearing in it cannot be generalized. This is what this
message says: 'a is not a generalizable variable. Maybe printing it as
'_a would be more intuitive.
And yes, this is slightly in contradiction with the above explanation:
if 'a does not matter, why can't we generalize it? Well, these unused
variables are a pain anyway. They are only useful if you want to make
an abstract type out of eventdesc, and you will not get a coherent
behaviour otherwise. Actually your program might be accepted in future
versions.
The text was updated successfully, but these errors were encountered: