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 DEF60BB81 for ; Fri, 13 Jan 2006 05:59:18 +0100 (CET) Received: from rabbit.math.nagoya-u.ac.jp (rabbit.math.nagoya-u.ac.jp [133.6.130.5]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0D4xGem014081 for ; Fri, 13 Jan 2006 05:59:18 +0100 Received: from localhost (millas [172.16.30.29]) by rabbit.math.nagoya-u.ac.jp (8.12.11/3.7W) with ESMTP id k0D4wuoE018157; Fri, 13 Jan 2006 13:58:56 +0900 (JST) Date: Fri, 13 Jan 2006 13:57:16 +0900 (JST) Message-Id: <20060113.135716.226786926.garrigue@math.nagoya-u.ac.jp> To: skaller@users.sourceforge.net Cc: jonathan.roewen@gmail.com, caml-list@yquem.inria.fr Subject: Re: [Caml-list] Mixing variant types... From: Jacques Garrigue In-Reply-To: <1137038225.3681.178.camel@rosella> References: <20060112.122230.45186948.garrigue@math.nagoya-u.ac.jp> <1137038225.3681.178.camel@rosella> X-Mailer: Mew version 4.0.69 on Emacs 22.0.50 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 43C733A5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 mli:01 rebuilt:01 ocaml:01 3.09.0:01 ocamlc:01 -thread:01 28,:98 sourceforge:01 expression:01 flx:01 jacques:01 jacques:01 variant:02 variant:02 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 From: skaller > 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) The + above is not needed (it is implied by the definition) > (* event.mli *) > type +'a event That + is sufficient. > 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 You still need to coerce the resulting list: (List.map (fun w -> receive w.control) !windows :> ws_event list) Jacques