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: 6723 Reporter:@zoggy Status: closed (set by @zoggy on 2014-12-18T14:23:30Z) Resolution: not a bug Priority: normal Severity: minor Version: 4.02.1 Category: typing
Bug description
I'd like to create functors taking in parameter a module with an extensible type t:
module type P = sig type t = .. end
module F (P:P) = struct type P.t += TFoo of int end
module G (P:P) = struct type P.t += TBar of float end
module P1 = struct type t = .. end
module F1 = F(P1)
module G1 = F(P1)
Now the problem is that I can't refer to TFoo or TBar constructors, except of course respectively in the bodies of functors F an G.
I tried a workaround like this:
module G (P:P) = struct
type b = TBar of float
type P.t += TBar = TBar
end
But in this case, I get:
Error: The constructor TBar has type b but was expected to be of type P.t
The documentation is not clear about rebinding extensible variant constructors. The provided example, type Expr.attr += Str = Expr.Str seems of limited interest as Str is rebound to ... Str ?
The text was updated successfully, but these errors were encountered:
It's true that the manual does not say clearly that extension constructors are scoped by the module where they are defined. Developers are used to be able to access constructors directly when their type is in scope, but of course, this cannot work with extensible types.
Original bug ID: 6723
Reporter: @zoggy
Status: closed (set by @zoggy on 2014-12-18T14:23:30Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 4.02.1
Category: typing
Bug description
I'd like to create functors taking in parameter a module with an extensible type t:
module type P = sig type t = .. end
module F (P:P) = struct type P.t += TFoo of int end
module G (P:P) = struct type P.t += TBar of float end
module P1 = struct type t = .. end
module F1 = F(P1)
module G1 = F(P1)
Now the problem is that I can't refer to TFoo or TBar constructors, except of course respectively in the bodies of functors F an G.
I tried a workaround like this:
module G (P:P) = struct
type b = TBar of float
type P.t += TBar = TBar
end
But in this case, I get:
Error: The constructor TBar has type b but was expected to be of type P.t
The documentation is not clear about rebinding extensible variant constructors. The provided example, type Expr.attr += Str = Expr.Str seems of limited interest as Str is rebound to ... Str ?
The text was updated successfully, but these errors were encountered: