Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Damien <Damien.Pous@ens-lyon.fr>
To: caml-list@inria.fr
Subject: [Caml-list] functors and objects
Date: Tue, 3 Feb 2004 19:06:35 +0100	[thread overview]
Message-ID: <20040203190635.6cc61ff0.Damien.Pous@ens-lyon.fr> (raw)

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


             reply	other threads:[~2004-02-03 18:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-03 18:06 Damien [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040203190635.6cc61ff0.Damien.Pous@ens-lyon.fr \
    --to=damien.pous@ens-lyon.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox