From: skaller <skaller@users.sourceforge.net>
To: Jonathan Roewen <jonathan.roewen@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Mixing variant types...
Date: Thu, 12 Jan 2006 13:45:28 +1100 [thread overview]
Message-ID: <1137033928.3681.140.camel@rosella> (raw)
In-Reply-To: <ad8cfe7e0601111724t44b6966di5d803949161676ee@mail.gmail.com>
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 <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
next prev parent reply other threads:[~2006-01-12 2:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-11 10:36 Jonathan Roewen
2006-01-12 1:24 ` Jonathan Roewen
2006-01-12 2:45 ` skaller [this message]
2006-01-12 3:22 ` Jacques Garrigue
2006-01-12 3:57 ` skaller
2006-01-13 4:57 ` Jacques Garrigue
2006-01-13 7:56 ` skaller
2006-01-13 9:37 ` Jacques Garrigue
2006-01-12 3:59 ` Jonathan Roewen
-- strict thread matches above, loose matches on Subject: below --
2006-01-11 9:56 Jonathan Roewen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1137033928.3681.140.camel@rosella \
--to=skaller@users.sourceforge.net \
--cc=caml-list@yquem.inria.fr \
--cc=jonathan.roewen@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox