Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] functors and objects
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-02-03 (19:40)
From: Matt Gushee <mgushee@h...>
Subject: Re: [Caml-list] functors and objects'
On Tue, Feb 03, 2004 at 07:06:35PM +0100, Damien wrote:
> I would like to write something like
> <<
> class type o = 
> object 
> 	method react: unit
> end
> module type O = 
> sig
> 	type t :> o (* sigh... *)
> end

The first problem is that you're mixing type declarations and class
casts ... not a hard mistake to make, since the class cast syntax is a
bit confusing, and doesn't seem to be explained very well anywhere.
Anyway, you seem to have missed the simplest solution:

  module type O =
      type t = o

> module R(M: O') = 
> struct
> 	include R(M)

I don't see how this can work, because this module R takes an argument
of type O', whereas the other R (do you really want to give them the
same name?) takes an argument of type O. Regardless of their contents,
they are different interfaces and thus not interchangeable. There's
undoubtedly a way to achieve the result you want, but I don't really
understand what you are trying to do. Do you actually have a specific
goal in mind, or are you just experimenting?

Matt Gushee                 When a nation follows the Way,
Englewood, Colorado, USA    Horses bear manure through           its fields;   When a nation ignores the Way,
                            Horses bear soldiers through
                                its streets.
                            --Lao Tzu (Peter Merel, trans.)

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: