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: 3476 Reporter: administrator Assigned to:@xavierleroy Status: closed (set by @xavierleroy on 2006-08-30T11:57:53Z) Resolution: won't fix Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general) Related to:#4049#4615#5058 Child of:#5302 Monitored by:@lpw25@mmottl
Bug description
Hi,
this mail has already been sent to you once, but didn't show up in the
bug tracker (possibly a problem with the mail agent). To make sure you
get it, here it is again:
We have observed strange behaviour of the type checker when using
functors.
The following code does not compile:
module FF(X : sig end) =
struct
type t
end
module M =
struct
module X = struct end
module Y = FF (X) (* XXX *)
type t = Y.t
end
module F
(Y : sig type t end)
(M : sig type t = Y.t end) =
struct
end
module N = F (M.Y) (M)
The error is:
Signature mismatch:
Modules do not match:
sig
module X : sig end
module Y : sig type t = FF(X).t end
type t = Y.t
end
is not included in
sig type t = M.Y.t end
Type declarations do not match:
type t = Y.t
is not included in
type t = M.Y.t
However, if we replace the line marked with "XXX" as follows (i.e.
expand the definition of the argument "X"):
module Y = FF (struct end)
then the code compiles without problems. Are we overlooking a trivial
reason why the first code should be incorrect?
This is an unfortunate consequence of applicative functors.
In the example, there are two valid but incompatible signatures for M.Y:
M.Y : sig type t = FF(M.X).t end (because of applicative functors)
and
M.Y : sig type t = M.Y.t end (by regular strengthening)
Since the OCaml module system can only express one equality per type component of a structure, both type equalities cannot be expressed, and the system
chooses the first signature, while the second is what is needed to satisfy the sharing constraint in functor F. Replacing FF(X) by FF(struct end)
renders the special case for applicative functors inapplicable and the problem goes away.
I agree this is an unfortunate side-effect of applicative functors, and there are other such side-effects (see PR #4049 for instance). There are no easy fixes: removing app. funct. would break too much code, and making sure app. funct. never cause such information loss is basically an open problem that would certainly require a major rewrite of the module type-checker. So, chalk it on bad design if you want, but I'm afraid this is a "won't fix" situation.
following two type equations hold concerning M.Y.t:
M.Y.t = FF(M.X).t because of applicative functors, and
M.Y.t = M.Y.t
Original bug ID: 3476
Reporter: administrator
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2006-08-30T11:57:53Z)
Resolution: won't fix
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Related to: #4049 #4615 #5058
Child of: #5302
Monitored by: @lpw25 @mmottl
Bug description
Hi,
this mail has already been sent to you once, but didn't show up in the
bug tracker (possibly a problem with the mail agent). To make sure you
get it, here it is again:
We have observed strange behaviour of the type checker when using
functors.
The following code does not compile:
module FF(X : sig end) =
struct
type t
end
module M =
struct
module X = struct end
module Y = FF (X) (* XXX *)
type t = Y.t
end
module F
(Y : sig type t end)
(M : sig type t = Y.t end) =
struct
end
module N = F (M.Y) (M)
The error is:
Signature mismatch:
Modules do not match:
sig
module X : sig end
module Y : sig type t = FF(X).t end
type t = Y.t
end
is not included in
sig type t = M.Y.t end
Type declarations do not match:
type t = Y.t
is not included in
type t = M.Y.t
However, if we replace the line marked with "XXX" as follows (i.e.
expand the definition of the argument "X"):
module Y = FF (struct end)
then the code compiles without problems. Are we overlooking a trivial
reason why the first code should be incorrect?
Our compiler version is 3.08.2.
Best regards,
Markus
--
Markus Mottl mmottl@janestcapital.com
The text was updated successfully, but these errors were encountered: