caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] functors and objects
@ 2004-02-03 18:06 Damien
  2004-02-03 19:37 ` Matt Gushee
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Damien @ 2004-02-03 18:06 UTC (permalink / raw)
  To: caml-list

Hello,

I would like to write something like

<<
class type o = 
object 
	method react: unit
end

module type O = 
sig
	type t :> o (* sigh... *)
end

module R(M: O) = 
struct
	let l: M.t list ref = []
	let register (o: M.t) = l := o :: !l
	let react() = List.iter (fun o -> o#react) !l
end
>>

and then, in a second layer, something like 

<<
class type o' = 
object 
	inherit o
	method render: unit
end

module type O' = 
sig
	type t :> o' 
end

module R(M: O') = 
struct
	include R(M)
	let render() = List.iter (fun o -> o#render) !l
end
>>

I tried all sort of tricks with #o, type 'a t = #o as 'a ...
but I didn't managed to to it :(
(without turning my objects into plain modules)

Any idea ?

Is it unsound to let a functor use an object type ?
(not to inherit from the class, 
just to use the methods of objects belonging to this type)

thanks,
damien

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-02-06  1:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-03 18:06 [Caml-list] functors and objects Damien
2004-02-03 19:37 ` Matt Gushee
2004-02-03 19:39 ` [Caml-list] functors and objects' Matt Gushee
2004-02-03 20:26   ` Damien Pous
2004-02-04  2:57 ` [Caml-list] functors and objects Jacques Garrigue
2004-02-05  8:55   ` Damien
2004-02-05  9:18     ` Jacques Garrigue
2004-02-05 13:45       ` Damien
2004-02-06  1:30         ` Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).