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
Recursive modules need qualified names? #2660
Comments
Comment author: administrator
Even if you use the fuly-qualified names, your program won't do what
The evaluation of this 'module rec' proceeds as outlined in the The correct solution is to do eta-expansion to delay the computation
The workaround you proposed:
doesn't solve the problem entirely: the "inj" function works correctly I agree the semantics of "module rec" aren't particularly intuitive, Hope this clarifies the issue.
|
Comment author: administrator Feature wish: static detection of ill-founded "module rec". |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
See #2629 for another example where eta-expansion is needed. We haven't made progress towards static detection of ill-founded "module rec" in 16 years, so I'll close this report. |
Original bug ID: 2660
Reporter: administrator
Status: acknowledged
Resolution: open
Priority: normal
Severity: feature
Category: typing
Tags: recmod
Monitored by: "Julien Signoles"
Bug description
Full_Name: Christopher Dutchyn
Version: 3.07+2
OS: Windows XP
Submission from: cypress.cs.ubc.ca (142.103.11.23)
In the attached code, why does MakeMiddle.{inj,op} need to fully qualify the
names imported as Above.top{Ext,Inj,Op} rather than using the otherwise
intra-module names topExt, topInj, and topOp (look for the lines with !!!!)? If
you use the intra-module names, then you get errors about missing recursive
modules.
Chris D.
module type LAYER =
sig
(* open recursion to top layer *)
type topT
type topV
val topInj : string -> topT
val topOp : topT -> topV
val topExt : topV -> string
end
(* base module -- no lower layer present, empty types, all operations are errors
*)
module MakeBase (Above : LAYER)
: LAYER with type topT = Above.topT
and type topV = Above.topV =
struct
type topT = Above.topT
type topV = Above.topV
let topInj = Above.topInj
let topOp = Above.topOp
let topExt = Above.topExt
end
(* an intermediate level *)
module MakeMiddle (Below : LAYER)
(Above : LAYER)
: LAYER with type topT = Above.topT
and type topV = Above.topV =
struct
type topT = Above.topT
type topV = Above.topV
let topInj = Above.topInj (use Above.topInj in code within this
module)
let topOp = Above.topOp (ditto)
let topExt = Above.topExt (ditto)
<Below.T> *)
match (String.get s 0) with
| '1' -> OneT (String.get s 1)
| '2' -> TwoT(String.get s 1, Above.topInj (String.sub s 2 ((String.length
s)-2))) (why is Above. needed here? !!!!)
| _ -> BelowT (Below.inj s)
(Above.topOp t))) (ditto !!!!)
end
(* imagine there were more levels -- maybe even tree/graph structured *)
(* cap level -- close the open recursion of topXXX *)
module MakeCap (Below : LAYER) : LAYER =
struct
type t = Below.t
type v = Below.v
end
(* simplest test *)
module rec B : LAYER = MakeBase(T)
and T : LAYER = MakeCap(B)
(* simple test )
module rec B : LAYER = MakeBase(M)
and M : LAYER = MakeMiddle(B)(T)
( imagine there were more levels *)
and T : LAYER = MakeCap(M)
;; T.topInj "1x"
;; T.topOp (T.topInj "1x")
;; T.topExt (T.topOp (T.topInj "1x"))
;; T.topInj "2x1x"
;; T.topOp (T.topInj "2x1x")
;; T.topExt (T.topOp (T.topInj "2x1x"))
The text was updated successfully, but these errors were encountered: