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 6E834BB81 for ; Thu, 12 Jan 2006 03:45:43 +0100 (CET) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0C2jfI1031511 for ; Thu, 12 Jan 2006 03:45:42 +0100 Received: from rosella (ppp33-253.lns1.syd6.internode.on.net [59.167.33.253]) by smtp3.adl2.internode.on.net (8.13.5/8.13.5) with ESMTP id k0C2jSV5017361; Thu, 12 Jan 2006 13:15:28 +1030 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] Mixing variant types... From: skaller To: Jonathan Roewen Cc: caml-list@yquem.inria.fr In-Reply-To: References: Content-Type: text/plain Date: Thu, 12 Jan 2006 13:45:28 +1100 Message-Id: <1137033928.3681.140.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 43C5C2D5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 wrote:01 sourceforge:01 variant:02 match:02 types:02 module:03 module:03 let:03 let:03 chan:05 chan:05 problem:05 thu:05 channel:05 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 14:24 +1300, Jonathan Roewen wrote: > So, it all works fine & dandy. So I'm trying to duplicate this with my > window system problem. [ .. ] Try this: (* Module Channel *) type ('a,'b) channel = { source: 'a; chan: ('a * 'b) Event.channel; } let send channel value = Event.send channel.chan (channel.source, value) let receive channel = Event.receive channel.chan (* Module Window_system *) type event = [ `Repaint ] type control = [ `New_window ] type ec = [ event | control ] type window = { control: (window, event) channel; } type ws_event = (window * ec) Event.event let run () = let internal_control = Event.new_channel () in while true do let sources = ((Event.receive internal_control) :> ws_event) :: List.map (fun w -> Event.wrap (receive w.control) (fun (w,e) -> w, (e:> ec)) ) [] (* !windows .. *) in match Event.select sources with | (source, `Repaint) -> () (* repaint source *) | _ -> () done ;; -- John Skaller Felix, successor to C++: http://felix.sf.net