Browse thread
Fwd: "ocaml_beginners"::[] Trouble combining polymorphic classes and polymorphic methods
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Geoffrey Romer <geoff.romer@g...> |
| Subject: | Fwd: "ocaml_beginners"::[] Trouble combining polymorphic classes and polymorphic methods |
[escalated from ocaml_beginners, where I got no response] I'm trying to create a polymorphic class 'a foo which has a polymorphic method that takes as a parameter another foo object, but one with arbitrary type. In other words, something like this: class virtual ['a] foo = object (self) method virtual bar : 'b. 'b foo -> unit end;; When I try to compile this, though, I get a warning that I "cannot quantify 'b because it escapes this scope". When I drop the " 'b. " it compiles fine, but the reported type for bar is 'a foo -> unit; i.e. it's no longer polymorphic. Is there a problem with trying to make a method polymorphic with respect to the class type in this way? How can I make this work?