caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: 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:03:44 +0200	[thread overview]
Message-ID: <4F86E0C0.8020003@frisch.fr> (raw)
In-Reply-To: <CAPFanBHbb1uKg3zTy7AsjCehtcofZhs-KJzCi5d7=J7B=+twJA@mail.gmail.com>

I'll let Leo answer all your questions.  Here are just my 2 cents:

On 04/12/2012 02:56 PM, Gabriel Scherer wrote:
> 3. What is the semantics of making a *constructor* private?

I guess the idea is to allow pattern matching on that constructor, but 
not using it in positive position (to construct a value).

> 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.


Alain

  reply	other threads:[~2012-04-12 14:03 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 [this message]
2012-04-12 14:16     ` Philippe Veber
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=4F86E0C0.8020003@frisch.fr \
    --to=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).