caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Teller <David.Teller@univ-orleans.fr>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Auto-closing polymorphic variants ?
Date: Thu, 21 Feb 2008 13:21:31 +0100	[thread overview]
Message-ID: <1203596491.6304.18.camel@Blefuscu> (raw)
In-Reply-To: <20080221.105405.42787647.garrigue@math.nagoya-u.ac.jp>

On Thu, 2008-02-21 at 10:54 +0900, Jacques Garrigue wrote:
> This does not mean that we can try nothing. For instance we could
> introduce a warning when a pattern matching adds a new tag to a
> polymorphic input. The idea is that since the input is polymorphic, it
> is sure that it will never actually contain extra tags.
> And thanks to the relaxed value restriction, the result of safe_div
> would be just polymorphic enough to trigger the warning, while example
> like the above, by being not polymorphic, would not trigger it.
> But this would not be easy to implement...

Sounds like a good idea. How hard would that be ?

> > Of course, we could do that by manually closing the type of safe_div,
> > but this would essentially mean duplicating information.
> > 

> It is better to either define safe_div as returning a closed variant
> type (writing interfaces in ocaml _is not_ code duplication, it is
> code specification!) or not use wild cards in pattern matchings
> on open polymorphic variants.

I agree that, whenever module barriers are crossed, interfaces become
specifications. However, as soon as you're remaining inside one module,
it's nice to be more lightweight and just let inference handle
everything. This is where a warning (or something like a "close"
operator) would come in handy.

Cheers,
 David
-- 
David Teller
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
 Angry researcher: French Universities need reforms, but the LRU act brings liquidations. 


      reply	other threads:[~2008-02-21 12:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-20 20:57 David Teller
2008-02-21  0:29 ` [Caml-list] " Martin Jambon
2008-02-21 10:46   ` David Teller
2008-02-21  1:54 ` Jacques Garrigue
2008-02-21 12:21   ` David Teller [this message]

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=1203596491.6304.18.camel@Blefuscu \
    --to=david.teller@univ-orleans.fr \
    --cc=caml-list@inria.fr \
    --cc=garrigue@math.nagoya-u.ac.jp \
    /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).