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
include et application de foncteur #8451
Comments
Comment author: administrator Bonjour Julien,
Tu es tombé sur une faiblesse connue des modules applicatifs. En
alors A.t = F(X).t et B.t = F(Y).t, mais on n'a pas F(X).t = F(Y).t, Dans ton exemple, on voit apparaître le problème avec les types
alors que le reste du code exige t = G.t. Avec l'include expansé à la main, le "strengthening" est fait sur
Et si tu changes "module W=V module S=Set.Make(W)" par "module S=Set.Make(V)",
Enfin, si on met une contrainte de signature pour oublier tout ce module Labeled (V: COMPARABLE) : S = Bref, c'est la pagaille, mais je ne vois pas comment corriger cela Amitiés,
|
Comment author: administrator This boils down to F(A).t != F(B).t even if A is defined as equal to B. The |
Comment author: @xavierleroy Option -no-app-funct, introduced in 3.12.0, is effective here and in many similar examples: the given code sample typechecks fine with -no-app-funct. |
Original bug ID: 2049
Reporter: administrator
Status: closed (set by @xavierleroy on 2013-08-31T10:46:13Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 3.12.0
Category: ~DO NOT USE (was: OCaml general)
Monitored by: "Julien Signoles"
Bug description
Full_Name: Julien Signoles
Version: 3.06 / 3.07
OS: Linux
Submission from: pc8-123.lri.fr (129.175.8.123)
Bonjour,
Il semble y avoir un bug dans l'application de foncteurs et les includes.
Le code joint ci-dessous ne compile pas. Or il compile avec succès si
(cf le premier commentaire)
ou bien si
(cf le second commentaire)
Cordialement,
Julien Signoles et Jean-Christophe Filliâtre
module type COMPARABLE = sig
type t
val compare : t -> t -> int
val hash : t -> int
val equal : t -> t -> bool
end
module type S = sig
module Vertex : COMPARABLE
type t
val iter_edges : (Vertex.t -> unit) -> t -> unit
end
module Iterator(G : S) = struct
module P = struct
type t = G.Vertex.t
let compare _ _ = assert false
let equal _ _ = assert false
let hash _ = assert false
end
module H = Hashtbl.Make(P)
let iter_edges f g =
let h = H.create 97 in
G.iter_edges (fun v1 -> H.add h v1 ()) g
end
module Labeled (V: COMPARABLE) : S =
struct
module G = struct
module Vertex = V
(* ceci marche:
module S = Set.Make(V)
*)
end
include G
(* une inclusion manuelle fonctionne ?galement:
module Vertex = G.Vertex
module W = G.W
type t = G.t
let iter_edges = G.iter_edges
*)
include Iterator(G)
end
The text was updated successfully, but these errors were encountered: