MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16482.33127.497203.821118 at soggy.deldotd.com> Date: Wed, 24 Mar 2004 22:51:19 -0800 To: lablgtk at kaba.or.jp Subject: event variant types From: briand at aracnet.com Well maybe. I'm new to ocaml and the type system has got me a bit confused. Essentially I'd like to create a function and associated variant so that I can pass multiple event types as one argument: let fun event = match event with mouse_event -> | button_event -> | keypress_event -> ; So I tried a type which looks like : type an_event = E1 of GdkEvent.Motion.t | E2 of GdkEvent.Key.t | E3 of GdkEvent.Button.t ;; and a match which looks like let multi_event_procedure drawv event = ... match event with E1(event) -> true | E2(event) -> true | E3(event) -> true; which is in a routine which is invoked : area#event#add [`BUTTON_PRESS]; w#event#connect#button_press ~callback: begin fun ev -> multi_event_procedure drawv ev; true end; which gives me the error : This expression has type GdkEvent.Button.t = GdkEvent.Button.types Gdk.event but is here used with type an_event Of course I think it should work or I wouldn't be bothering the list :-) Any help appreciated. Thanks Brian