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: | Jacques Garrigue <garrigue@m...> |
| Subject: | Re: [Caml-list] Mixing variant types... |
From: skaller <skaller@users.sourceforge.net> > 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) The + above is not needed (it is implied by the definition) > (* event.mli *) > type +'a event That + is sufficient. > 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 You still need to coerce the resulting list: (List.map (fun w -> receive w.control) !windows :> ws_event list) Jacques