caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jeremy Yallop <yallop@gmail.com>
To: Stephen Dolan <stephen.dolan@cl.cam.ac.uk>
Cc: Andreas Rossberg <rossberg@mpi-sws.org>,
	Gabriel Scherer <gabriel.scherer@gmail.com>,
	 Julien Blond <julien.blond@gmail.com>,
	David Allsopp <dra-news@metastack.com>,
	 OCaml mailing-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Empty polymorphic variant set
Date: Fri, 25 Nov 2016 16:59:39 +0000	[thread overview]
Message-ID: <CAAxsn=FdqNo_fv6GaK1vJvAYdEijzRdeWc0X+y1XpmnZrPSYqQ@mail.gmail.com> (raw)
In-Reply-To: <CA+mHimNSxnZp3AgxYZkzSq3y1DH_XsB65_pzFbyNPBJu_qSuTA@mail.gmail.com>

On 25 November 2016 at 16:50, Stephen Dolan <stephen.dolan@cl.cam.ac.uk> wrote:
> On Fri, Nov 25, 2016 at 1:52 PM, Andreas Rossberg <rossberg@mpi-sws.org>
> wrote:
>>
>>
>> > On Nov 25, 2016, at 14:46 , Gabriel Scherer <gabriel.scherer@gmail.com>
>> > wrote:
>> >
>> > I would agree that OCaml lacks a convenient way to define the empty
>> > type.
>>
>> Isn’t
>>
>>   type empty
>>
>> (as a definition) a sufficiently convenient way to define an empty type?
>
>
> I agree that that defines the empty type, but OCaml disagrees. OCaml takes
> that as declaring an abstract type, just as if you'd included a module
> exposing an opaque type. So, the compiler won't conclude that 'empty' is
> actually an empty type (viewing it as an unknown abstract type), nor will it
> refute (int, empty) eq.

There's a small (and not enormously useful) distinction to be made
here.  If 'empty' is in the current module then OCaml knows that
'empty' and 'int' are incompatible, and so accepts the following
program:

   type empty
   type (_,_) eql = Refl : ('a,'a) eql
   let f : (int, empty) eql -> unit = function _ -> .

However, if 'empty' is defined in a different module ('M', say) then
OCaml treats 'empty' and 'int' as compatible and so rejects the
following (non-)program:

   type (_,_) eql = Refl : ('a,'a) eql
   let f : (int, M.empty) eql -> unit = function _ -> .

Jeremy

      reply	other threads:[~2016-11-25 16:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-25  8:39 Julien Blond
2016-11-25  9:19 ` Ben Millwood
2016-11-25  9:20 ` Julien Blond
2016-11-25 11:22   ` David Allsopp
2016-11-25 13:01     ` Julien Blond
2016-11-25 13:46       ` Gabriel Scherer
2016-11-25 13:52         ` Andreas Rossberg
2016-11-25 15:42           ` Markus Mottl
2016-11-25 15:46           ` Gabriel Scherer
2016-11-25 15:59             ` Yaron Minsky
2016-11-25 16:42               ` Markus Mottl
2016-11-25 17:11                 ` Gabriel Scherer
2016-11-25 16:50           ` Stephen Dolan
2016-11-25 16:59             ` Jeremy Yallop [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='CAAxsn=FdqNo_fv6GaK1vJvAYdEijzRdeWc0X+y1XpmnZrPSYqQ@mail.gmail.com' \
    --to=yallop@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dra-news@metastack.com \
    --cc=gabriel.scherer@gmail.com \
    --cc=julien.blond@gmail.com \
    --cc=rossberg@mpi-sws.org \
    --cc=stephen.dolan@cl.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).