caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Philippe Veber <philippe.veber@gmail.com>
To: Alain Frisch <alain@frisch.fr>
Cc: Gabriel Scherer <gabriel.scherer@gmail.com>,
	Leo P White <lpw25@cam.ac.uk>, caml <caml-list@inria.fr>
Subject: Re: [Caml-list] [ANN] ocamlopen 1.0.2
Date: Thu, 12 Apr 2012 16:16:09 +0200	[thread overview]
Message-ID: <CAOOOohRd5jGiVJkwhWcsji3cRw=vG_GDt9yg1daZPbdggxaZeQ@mail.gmail.com> (raw)
In-Reply-To: <4F86E0C0.8020003@frisch.fr>

[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]

>
> 4. When would you say that one should use polymorphic variants rather
>> than your open datatypes? (I know how to argue in the other direction:
>> unique constructors make for better error messages.)
>>
>
> I've wanted such open datatypes several times.  One example is a message
> bus across an application: some components can yield messages to be
> dispatched to all registered components.  Messages can hold data, and the
> set of possible messages (with the type of their associated data) is
> extensible (say, because components can be loaded dynamically, or just to
> make the application's architecture more modular).  It makes sense to use
> an extensible datatype to represent messages.  Components can react to
> messages with pattern-matching and two components can interact if their
> share a common constructor definition.  This is simpler than encoding open
> datatypes with a "universal" type (with injections/projections).  Of
> course, one can use the existing "exn" type, but then we don't distinguish
> between exceptions and messages at all.
>

Isn't this a good use case for polymorphic variants too ? Compared to open
datatypes, you could suffer from the weaker type checks though: if two
components are supposed to communicate through a constructor, which is
mispelled in one of the component, the error would not be noticed by the
compiler.

my own 2 cent ...
philippe.

[-- Attachment #2: Type: text/html, Size: 1805 bytes --]

  reply	other threads:[~2012-04-12 14:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-11 21:13 Leo P White
2012-04-12 12:56 ` Gabriel Scherer
2012-04-12 14:03   ` Alain Frisch
2012-04-12 14:16     ` Philippe Veber [this message]
2012-04-12 14:29       ` Alain Frisch
2012-04-17 10:02         ` Philippe Veber
2012-04-12 17:07   ` Leo P White
2012-04-12 17:21     ` Alain Frisch
2012-04-12 20:31       ` Leo P White

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='CAOOOohRd5jGiVJkwhWcsji3cRw=vG_GDt9yg1daZPbdggxaZeQ@mail.gmail.com' \
    --to=philippe.veber@gmail.com \
    --cc=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@gmail.com \
    --cc=lpw25@cam.ac.uk \
    /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;
as well as URLs for NNTP newsgroup(s).