From: Ben Millwood <bmillwood@janestreet.com>
To: Julien Blond <julien.blond@gmail.com>
Cc: OCaml mailing-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Empty polymorphic variant set
Date: Fri, 25 Nov 2016 17:19:30 +0800 [thread overview]
Message-ID: <CA+MHO52U49u3yBsWBxyL6DC45FxvkotRdPMJsyXb9cvx-wcOYg@mail.gmail.com> (raw)
In-Reply-To: <CAG3nF7UywqZo6t5PRi4WHhYcQn+qe7qmUR5FZBGyWz-DWqtNPw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]
After playing around with this for a little while, it looks to me like
type t = []
isn't defining t as a synonym for the empty polyvariant, but rather
defining t to be an ADT with one constructor, []. In particular, note that
type t = []
type s = []
let f (x : s) : t = x (* does not typecheck *)
type r = t = [] (* parses fine, showing [] is a constructor *)
let f [] = () (* no exhaustivity warnings, inferred type is f : r ->
unit *)
It's odd that [] is a valid constructor name, but I suppose we want it so
for lists, and might as well let other people reuse it.
On 25 November 2016 at 16:39, Julien Blond <julien.blond@gmail.com> wrote:
> Hi,
>
> Let's try something :
>
> $ ocaml
> OCaml version 4.03.0
>
> # let _ : [] list = [];;
> Characters 9-10:
> let _ : [] list = [];;
>
> Error: Syntax error
> # type empty = [];;
> type empty = []
> # let _ : empty list = [];;
> - : empty list = []
> #
>
> Does anyone know if there is a reason to forbid the empty polymorphic
> variant set in type expressions or if it's a bug ?
>
> Regards,
>
> -- Julien Blond
>
[-- Attachment #2: Type: text/html, Size: 1792 bytes --]
next prev parent reply other threads:[~2016-11-25 9:19 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 [this message]
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
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=CA+MHO52U49u3yBsWBxyL6DC45FxvkotRdPMJsyXb9cvx-wcOYg@mail.gmail.com \
--to=bmillwood@janestreet.com \
--cc=caml-list@inria.fr \
--cc=julien.blond@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