caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Mixing variant types...
@ 2006-01-11  9:56 Jonathan Roewen
  0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Roewen @ 2006-01-11  9:56 UTC (permalink / raw)
  To: caml-list

Hi,

I'm wondering why the following doesn't work:

let sources = (Event.receive internal_control) :: List.map (fun w ->
Channel.receive w.control) !windows in

where internal_control passes a (window,`New_window) event over the
channel, and w.control passes values of the type (window,event), where
type event = [ `Repaint ].

I thought that since they're both variant types, I should be able to
build a list that uses both variants.

Hmm, I just had a thought: is this because it's a tuple with the
variant inside the tuple?

Jonathan


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [Caml-list] Mixing variant types...
@ 2006-01-11 10:36 Jonathan Roewen
  2006-01-12  1:24 ` Jonathan Roewen
  0 siblings, 1 reply; 10+ messages in thread
From: Jonathan Roewen @ 2006-01-11 10:36 UTC (permalink / raw)
  To: Christophe Dehlinger; +Cc: caml-list

> Hi,
>
> Have you tried explicitly casting event to an open variant type (or
> whatever they're called) ?
>
> let sources = (Event.receive internal_control) :: List.map (fun w ->
> Channel.receive (w.control :> 'a * [> event ]) !windows in

Hmm, I tried that, and also:

let sources = (Event.receive internal_control) :: List.map (fun w ->
((Channel.receive w.control) :> (window * [> event | `New_window ])
Event.event)) !windows in

I now get:

This expression cannot be coerced to type
  (window * ([> `New_window | `Repaint ] as 'a)) Event.event;
it has type (window * event) Event.event but is here used with type
  (window * 'a) Event.event
Type event = [ `Repaint ] is not compatible with type 'a
The first variant type does not allow tag(s) `New_window

Jonathan


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-01-13  9:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-11  9:56 [Caml-list] Mixing variant types Jonathan Roewen
2006-01-11 10:36 Jonathan Roewen
2006-01-12  1:24 ` Jonathan Roewen
2006-01-12  2:45   ` skaller
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).