Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: jonathan.roewen@gmail.com, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Mixing variant types...
Date: Thu, 12 Jan 2006 14:57:05 +1100	[thread overview]
Message-ID: <1137038225.3681.178.camel@rosella> (raw)
In-Reply-To: <20060112.122230.45186948.garrigue@math.nagoya-u.ac.jp>

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


  reply	other threads:[~2006-01-12  3:57 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
2006-01-12  3:22   ` Jacques Garrigue
2006-01-12  3:57     ` skaller [this message]
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=1137038225.3681.178.camel@rosella \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@yquem.inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    --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