Skip to content
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

module/functor typing bug #3372

Closed
vicuna opened this issue Jun 4, 2002 · 2 comments
Closed

module/functor typing bug #3372

vicuna opened this issue Jun 4, 2002 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jun 4, 2002

Original bug ID: 1180
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Sami Mäkelä
Version: O'Caml 3.04
OS: Linux
Submission from: cccl.rdyn.saunalahti.fi (195.197.127.50)

I have a problem with complex functor application.
Everything works correctly if Z1 and Z2 are in different files or if
the argument functors are declared before they are used.

The problem this code is supposed to solve is that I have
several different modules with same interface S, and I want to write
some code parameterized by them, but I don't want to apply the
functor for all of the modules.

module type S = sig
type t
end

module type T = functor (S:S) -> sig
type t
val f : t
end

module String = struct type t = string end

module M (F:T) = struct
module M2 = F (String)
end

module Z1 = M
(functor (K:S) -> struct
type t = K.t -> K.t
let f x = x
end)

module Z2 = M
(functor (K:S) -> struct
type t = K.t -> int
let f x = 0
end)

let _ = Z2.M2.f ""

@vicuna
Copy link
Author

vicuna commented Jun 6, 2002

Comment author: administrator

I have a problem with complex functor application.
Everything works correctly if Z1 and Z2 are in different files or if
the argument functors are declared before they are used.

You have indeed uncovered a subtle (and long-standing) bug in the module
type-checker, related to the handling of type paths of the form F(M).t.
The bug is of the "premature optimization" kind, so it's easy to fix
by removing the optimization :-)

The bug will be fixed in the forthcoming release 3.05 of OCaml.
Indeed, it is fixed in the working version that you can access at
http://camlcvs.inria.fr/ if you'd like to test.

Thanks for your feedback,

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Jun 6, 2002

Comment author: administrator

Fixed 2002-06-06 by XL

@vicuna vicuna closed this as completed Jun 6, 2002
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant