Browse thread
Re: [Caml-list] Mixing variant types...
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | skaller <skaller@u...> |
| Subject: | Re: [Caml-list] Mixing variant types... |
On Thu, 2006-01-12 at 12:22 +0900, Jacques Garrigue wrote:
> You can already simulate subtyping using Event.wrap:
> Event.wrap e (fun x -> (x : t1 :> t2))
> will turn a t1 event into a t2 event.
> (So this probably means that Event.event should be covariant to start
> with...)
>
> For practical applications, the solution suggested by skaller might be
> satisfactory too.
Err .. but my solution does use Event.wrap .. :
Event.wrap (receive w.control) (fun (w,e) -> w, (e:> ec))
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)
(* event.mli *)
type +'a event
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
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net