From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id D8A92BB81 for ; Thu, 12 Jan 2006 04:57:34 +0100 (CET) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0C3vWAc005850 for ; Thu, 12 Jan 2006 04:57:34 +0100 Received: from rosella (ppp33-253.lns1.syd2.internode.on.net [59.167.33.253] (may be forged)) by smtp1.adl2.internode.on.net (8.13.5/8.13.5) with ESMTP id k0C3v5Ax096551; Thu, 12 Jan 2006 14:27:06 +1030 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] Mixing variant types... From: skaller To: Jacques Garrigue Cc: jonathan.roewen@gmail.com, caml-list@yquem.inria.fr In-Reply-To: <20060112.122230.45186948.garrigue@math.nagoya-u.ac.jp> References: <20060112.122230.45186948.garrigue@math.nagoya-u.ac.jp> Content-Type: text/plain Date: Thu, 12 Jan 2006 14:57:05 +1100 Message-Id: <1137038225.3681.178.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 43C5D3AC.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 simulate:01 subtyping:01 mli:01 rebuilt:01 ocaml:01 3.09.0:01 ocamlc:01 -thread:01 28,:98 wrote:01 sourceforge:01 expression:01 flx:01 jacques:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Thu, 2006-01-12 at 12:22 +0900, Jacques Garrigue wrote: > You can already simulate subtyping using Event.wrap: > Event.wrap e (fun x -> (x : t1 :> t2)) > will turn a t1 event into a t2 event. > (So this probably means that Event.event should be covariant to start > with...) > > For practical applications, the solution suggested by skaller might be > satisfactory too. Err .. but my solution does use Event.wrap .. : Event.wrap (receive w.control) (fun (w,e) -> w, (e:> ec)) I just tried making Event.event covariant but it didn't seem to work, perhaps I did something wrong here? (* event.ml *) type +'a event = Communication of 'a behavior | Choose of 'a event list | WrapAbort of 'a event * (unit -> unit) | Guard of (unit -> 'a event) (* event.mli *) type +'a event Rebuilt and reinstalled Ocaml 3.09.0 .. changed example to: List.map (fun w -> (* Event.wrap (receive w.control) (fun (w,e) -> w, (e:> ec)) *) (receive w.control) ) [] (* !windows .. *) eliminating the Event.wrap and hoping this would fix it .. skaller@rosella:/work/felix/flx$ ocamlc -thread r.ml File "r.ml", line 28, characters 6-143: This expression has type (window * event) Event.event list but is here used with type ws_event list Type (window * event) Event.event is not compatible with type ws_event = (window * ec) Event.event Type event = [ `Repaint ] is not compatible with type ec = [ `New_window | `Repaint ] The first variant type does not allow tag(s) `New_window -- John Skaller Felix, successor to C++: http://felix.sf.net